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,42 @@
1
+ This directory contains examples of the use of zlib.
2
+
3
+ fitblk.c
4
+ compress just enough input to nearly fill a requested output size
5
+ - zlib isn't designed to do this, but fitblk does it anyway
6
+
7
+ gun.c
8
+ uncompress a gzip file
9
+ - illustrates the use of inflateBack() for high speed file-to-file
10
+ decompression using call-back functions
11
+ - is approximately twice as fast as gzip -d
12
+ - also provides Unix uncompress functionality, again twice as fast
13
+
14
+ gzappend.c
15
+ append to a gzip file
16
+ - illustrates the use of the Z_BLOCK flush parameter for inflate()
17
+ - illustrates the use of deflatePrime() to start at any bit
18
+
19
+ gzjoin.c
20
+ join gzip files without recalculating the crc or recompressing
21
+ - illustrates the use of the Z_BLOCK flush parameter for inflate()
22
+ - illustrates the use of crc32_combine()
23
+
24
+ gzlog.c
25
+ gzlog.h
26
+ efficiently maintain a message log file in gzip format
27
+ - illustrates use of raw deflate and Z_SYNC_FLUSH
28
+ - illustrates use of gzip header extra field
29
+
30
+ zlib_how.html
31
+ painfully comprehensive description of zpipe.c (see below)
32
+ - describes in excruciating detail the use of deflate() and inflate()
33
+
34
+ zpipe.c
35
+ reads and writes zlib streams from stdin to stdout
36
+ - illustrates the proper use of deflate() and inflate()
37
+ - deeply commented in zlib_how.html (see above)
38
+
39
+ zran.c
40
+ index a zlib or gzip stream and randomly access it
41
+ - illustrates the use of Z_BLOCK, inflatePrime(), and
42
+ inflateSetDictionary() to provide random access
@@ -0,0 +1,233 @@
1
+ /* fitblk.c: example of fitting compressed output to a specified size
2
+ Not copyrighted -- provided to the public domain
3
+ Version 1.1 25 November 2004 Mark Adler */
4
+
5
+ /* Version history:
6
+ 1.0 24 Nov 2004 First version
7
+ 1.1 25 Nov 2004 Change deflateInit2() to deflateInit()
8
+ Use fixed-size, stack-allocated raw buffers
9
+ Simplify code moving compression to subroutines
10
+ Use assert() for internal errors
11
+ Add detailed description of approach
12
+ */
13
+
14
+ /* Approach to just fitting a requested compressed size:
15
+
16
+ fitblk performs three compression passes on a portion of the input
17
+ data in order to determine how much of that input will compress to
18
+ nearly the requested output block size. The first pass generates
19
+ enough deflate blocks to produce output to fill the requested
20
+ output size plus a specfied excess amount (see the EXCESS define
21
+ below). The last deflate block may go quite a bit past that, but
22
+ is discarded. The second pass decompresses and recompresses just
23
+ the compressed data that fit in the requested plus excess sized
24
+ buffer. The deflate process is terminated after that amount of
25
+ input, which is less than the amount consumed on the first pass.
26
+ The last deflate block of the result will be of a comparable size
27
+ to the final product, so that the header for that deflate block and
28
+ the compression ratio for that block will be about the same as in
29
+ the final product. The third compression pass decompresses the
30
+ result of the second step, but only the compressed data up to the
31
+ requested size minus an amount to allow the compressed stream to
32
+ complete (see the MARGIN define below). That will result in a
33
+ final compressed stream whose length is less than or equal to the
34
+ requested size. Assuming sufficient input and a requested size
35
+ greater than a few hundred bytes, the shortfall will typically be
36
+ less than ten bytes.
37
+
38
+ If the input is short enough that the first compression completes
39
+ before filling the requested output size, then that compressed
40
+ stream is return with no recompression.
41
+
42
+ EXCESS is chosen to be just greater than the shortfall seen in a
43
+ two pass approach similar to the above. That shortfall is due to
44
+ the last deflate block compressing more efficiently with a smaller
45
+ header on the second pass. EXCESS is set to be large enough so
46
+ that there is enough uncompressed data for the second pass to fill
47
+ out the requested size, and small enough so that the final deflate
48
+ block of the second pass will be close in size to the final deflate
49
+ block of the third and final pass. MARGIN is chosen to be just
50
+ large enough to assure that the final compression has enough room
51
+ to complete in all cases.
52
+ */
53
+
54
+ #include <stdio.h>
55
+ #include <stdlib.h>
56
+ #include <assert.h>
57
+ #include "zlib.h"
58
+
59
+ #define local static
60
+
61
+ /* print nastygram and leave */
62
+ local void quit(char *why)
63
+ {
64
+ fprintf(stderr, "fitblk abort: %s\n", why);
65
+ exit(1);
66
+ }
67
+
68
+ #define RAWLEN 4096 /* intermediate uncompressed buffer size */
69
+
70
+ /* compress from file to def until provided buffer is full or end of
71
+ input reached; return last deflate() return value, or Z_ERRNO if
72
+ there was read error on the file */
73
+ local int partcompress(FILE *in, z_streamp def)
74
+ {
75
+ int ret, flush;
76
+ unsigned char raw[RAWLEN];
77
+
78
+ flush = Z_NO_FLUSH;
79
+ do {
80
+ def->avail_in = fread(raw, 1, RAWLEN, in);
81
+ if (ferror(in))
82
+ return Z_ERRNO;
83
+ def->next_in = raw;
84
+ if (feof(in))
85
+ flush = Z_FINISH;
86
+ ret = deflate(def, flush);
87
+ assert(ret != Z_STREAM_ERROR);
88
+ } while (def->avail_out != 0 && flush == Z_NO_FLUSH);
89
+ return ret;
90
+ }
91
+
92
+ /* recompress from inf's input to def's output; the input for inf and
93
+ the output for def are set in those structures before calling;
94
+ return last deflate() return value, or Z_MEM_ERROR if inflate()
95
+ was not able to allocate enough memory when it needed to */
96
+ local int recompress(z_streamp inf, z_streamp def)
97
+ {
98
+ int ret, flush;
99
+ unsigned char raw[RAWLEN];
100
+
101
+ flush = Z_NO_FLUSH;
102
+ do {
103
+ /* decompress */
104
+ inf->avail_out = RAWLEN;
105
+ inf->next_out = raw;
106
+ ret = inflate(inf, Z_NO_FLUSH);
107
+ assert(ret != Z_STREAM_ERROR && ret != Z_DATA_ERROR &&
108
+ ret != Z_NEED_DICT);
109
+ if (ret == Z_MEM_ERROR)
110
+ return ret;
111
+
112
+ /* compress what was decompresed until done or no room */
113
+ def->avail_in = RAWLEN - inf->avail_out;
114
+ def->next_in = raw;
115
+ if (inf->avail_out != 0)
116
+ flush = Z_FINISH;
117
+ ret = deflate(def, flush);
118
+ assert(ret != Z_STREAM_ERROR);
119
+ } while (ret != Z_STREAM_END && def->avail_out != 0);
120
+ return ret;
121
+ }
122
+
123
+ #define EXCESS 256 /* empirically determined stream overage */
124
+ #define MARGIN 8 /* amount to back off for completion */
125
+
126
+ /* compress from stdin to fixed-size block on stdout */
127
+ int main(int argc, char **argv)
128
+ {
129
+ int ret; /* return code */
130
+ unsigned size; /* requested fixed output block size */
131
+ unsigned have; /* bytes written by deflate() call */
132
+ unsigned char *blk; /* intermediate and final stream */
133
+ unsigned char *tmp; /* close to desired size stream */
134
+ z_stream def, inf; /* zlib deflate and inflate states */
135
+
136
+ /* get requested output size */
137
+ if (argc != 2)
138
+ quit("need one argument: size of output block");
139
+ ret = strtol(argv[1], argv + 1, 10);
140
+ if (argv[1][0] != 0)
141
+ quit("argument must be a number");
142
+ if (ret < 8) /* 8 is minimum zlib stream size */
143
+ quit("need positive size of 8 or greater");
144
+ size = (unsigned)ret;
145
+
146
+ /* allocate memory for buffers and compression engine */
147
+ blk = malloc(size + EXCESS);
148
+ def.zalloc = Z_NULL;
149
+ def.zfree = Z_NULL;
150
+ def.opaque = Z_NULL;
151
+ ret = deflateInit(&def, Z_DEFAULT_COMPRESSION);
152
+ if (ret != Z_OK || blk == NULL)
153
+ quit("out of memory");
154
+
155
+ /* compress from stdin until output full, or no more input */
156
+ def.avail_out = size + EXCESS;
157
+ def.next_out = blk;
158
+ ret = partcompress(stdin, &def);
159
+ if (ret == Z_ERRNO)
160
+ quit("error reading input");
161
+
162
+ /* if it all fit, then size was undersubscribed -- done! */
163
+ if (ret == Z_STREAM_END && def.avail_out >= EXCESS) {
164
+ /* write block to stdout */
165
+ have = size + EXCESS - def.avail_out;
166
+ if (fwrite(blk, 1, have, stdout) != have || ferror(stdout))
167
+ quit("error writing output");
168
+
169
+ /* clean up and print results to stderr */
170
+ ret = deflateEnd(&def);
171
+ assert(ret != Z_STREAM_ERROR);
172
+ free(blk);
173
+ fprintf(stderr,
174
+ "%u bytes unused out of %u requested (all input)\n",
175
+ size - have, size);
176
+ return 0;
177
+ }
178
+
179
+ /* it didn't all fit -- set up for recompression */
180
+ inf.zalloc = Z_NULL;
181
+ inf.zfree = Z_NULL;
182
+ inf.opaque = Z_NULL;
183
+ inf.avail_in = 0;
184
+ inf.next_in = Z_NULL;
185
+ ret = inflateInit(&inf);
186
+ tmp = malloc(size + EXCESS);
187
+ if (ret != Z_OK || tmp == NULL)
188
+ quit("out of memory");
189
+ ret = deflateReset(&def);
190
+ assert(ret != Z_STREAM_ERROR);
191
+
192
+ /* do first recompression close to the right amount */
193
+ inf.avail_in = size + EXCESS;
194
+ inf.next_in = blk;
195
+ def.avail_out = size + EXCESS;
196
+ def.next_out = tmp;
197
+ ret = recompress(&inf, &def);
198
+ if (ret == Z_MEM_ERROR)
199
+ quit("out of memory");
200
+
201
+ /* set up for next reocmpression */
202
+ ret = inflateReset(&inf);
203
+ assert(ret != Z_STREAM_ERROR);
204
+ ret = deflateReset(&def);
205
+ assert(ret != Z_STREAM_ERROR);
206
+
207
+ /* do second and final recompression (third compression) */
208
+ inf.avail_in = size - MARGIN; /* assure stream will complete */
209
+ inf.next_in = tmp;
210
+ def.avail_out = size;
211
+ def.next_out = blk;
212
+ ret = recompress(&inf, &def);
213
+ if (ret == Z_MEM_ERROR)
214
+ quit("out of memory");
215
+ assert(ret == Z_STREAM_END); /* otherwise MARGIN too small */
216
+
217
+ /* done -- write block to stdout */
218
+ have = size - def.avail_out;
219
+ if (fwrite(blk, 1, have, stdout) != have || ferror(stdout))
220
+ quit("error writing output");
221
+
222
+ /* clean up and print results to stderr */
223
+ free(tmp);
224
+ ret = inflateEnd(&inf);
225
+ assert(ret != Z_STREAM_ERROR);
226
+ ret = deflateEnd(&def);
227
+ assert(ret != Z_STREAM_ERROR);
228
+ free(blk);
229
+ fprintf(stderr,
230
+ "%u bytes unused out of %u requested (%lu input)\n",
231
+ size - have, size, def.total_in);
232
+ return 0;
233
+ }
@@ -0,0 +1,693 @@
1
+ /* gun.c -- simple gunzip to give an example of the use of inflateBack()
2
+ * Copyright (C) 2003, 2005 Mark Adler
3
+ * For conditions of distribution and use, see copyright notice in zlib.h
4
+ Version 1.3 12 June 2005 Mark Adler */
5
+
6
+ /* Version history:
7
+ 1.0 16 Feb 2003 First version for testing of inflateBack()
8
+ 1.1 21 Feb 2005 Decompress concatenated gzip streams
9
+ Remove use of "this" variable (C++ keyword)
10
+ Fix return value for in()
11
+ Improve allocation failure checking
12
+ Add typecasting for void * structures
13
+ Add -h option for command version and usage
14
+ Add a bunch of comments
15
+ 1.2 20 Mar 2005 Add Unix compress (LZW) decompression
16
+ Copy file attributes from input file to output file
17
+ 1.3 12 Jun 2005 Add casts for error messages [Oberhumer]
18
+ */
19
+
20
+ /*
21
+ gun [ -t ] [ name ... ]
22
+
23
+ decompresses the data in the named gzip files. If no arguments are given,
24
+ gun will decompress from stdin to stdout. The names must end in .gz, -gz,
25
+ .z, -z, _z, or .Z. The uncompressed data will be written to a file name
26
+ with the suffix stripped. On success, the original file is deleted. On
27
+ failure, the output file is deleted. For most failures, the command will
28
+ continue to process the remaining names on the command line. A memory
29
+ allocation failure will abort the command. If -t is specified, then the
30
+ listed files or stdin will be tested as gzip files for integrity (without
31
+ checking for a proper suffix), no output will be written, and no files
32
+ will be deleted.
33
+
34
+ Like gzip, gun allows concatenated gzip streams and will decompress them,
35
+ writing all of the uncompressed data to the output. Unlike gzip, gun allows
36
+ an empty file on input, and will produce no error writing an empty output
37
+ file.
38
+
39
+ gun will also decompress files made by Unix compress, which uses LZW
40
+ compression. These files are automatically detected by virtue of their
41
+ magic header bytes. Since the end of Unix compress stream is marked by the
42
+ end-of-file, they cannot be concantenated. If a Unix compress stream is
43
+ encountered in an input file, it is the last stream in that file.
44
+
45
+ Like gunzip and uncompress, the file attributes of the orignal compressed
46
+ file are maintained in the final uncompressed file, to the extent that the
47
+ user permissions allow it.
48
+
49
+ On my Mac OS X PowerPC G4, gun is almost twice as fast as gunzip (version
50
+ 1.2.4) is on the same file, when gun is linked with zlib 1.2.2. Also the
51
+ LZW decompression provided by gun is about twice as fast as the standard
52
+ Unix uncompress command.
53
+ */
54
+
55
+ /* external functions and related types and constants */
56
+ #include <stdio.h> /* fprintf() */
57
+ #include <stdlib.h> /* malloc(), free() */
58
+ #include <string.h> /* strerror(), strcmp(), strlen(), memcpy() */
59
+ #include <errno.h> /* errno */
60
+ #include <fcntl.h> /* open() */
61
+ #include <unistd.h> /* read(), write(), close(), chown(), unlink() */
62
+ #include <sys/types.h>
63
+ #include <sys/stat.h> /* stat(), chmod() */
64
+ #include <utime.h> /* utime() */
65
+ #include "zlib.h" /* inflateBackInit(), inflateBack(), */
66
+ /* inflateBackEnd(), crc32() */
67
+
68
+ /* function declaration */
69
+ #define local static
70
+
71
+ /* buffer constants */
72
+ #define SIZE 32768U /* input and output buffer sizes */
73
+ #define PIECE 16384 /* limits i/o chunks for 16-bit int case */
74
+
75
+ /* structure for infback() to pass to input function in() -- it maintains the
76
+ input file and a buffer of size SIZE */
77
+ struct ind {
78
+ int infile;
79
+ unsigned char *inbuf;
80
+ };
81
+
82
+ /* Load input buffer, assumed to be empty, and return bytes loaded and a
83
+ pointer to them. read() is called until the buffer is full, or until it
84
+ returns end-of-file or error. Return 0 on error. */
85
+ local unsigned in(void *in_desc, unsigned char **buf)
86
+ {
87
+ int ret;
88
+ unsigned len;
89
+ unsigned char *next;
90
+ struct ind *me = (struct ind *)in_desc;
91
+
92
+ next = me->inbuf;
93
+ *buf = next;
94
+ len = 0;
95
+ do {
96
+ ret = PIECE;
97
+ if ((unsigned)ret > SIZE - len)
98
+ ret = (int)(SIZE - len);
99
+ ret = (int)read(me->infile, next, ret);
100
+ if (ret == -1) {
101
+ len = 0;
102
+ break;
103
+ }
104
+ next += ret;
105
+ len += ret;
106
+ } while (ret != 0 && len < SIZE);
107
+ return len;
108
+ }
109
+
110
+ /* structure for infback() to pass to output function out() -- it maintains the
111
+ output file, a running CRC-32 check on the output and the total number of
112
+ bytes output, both for checking against the gzip trailer. (The length in
113
+ the gzip trailer is stored modulo 2^32, so it's ok if a long is 32 bits and
114
+ the output is greater than 4 GB.) */
115
+ struct outd {
116
+ int outfile;
117
+ int check; /* true if checking crc and total */
118
+ unsigned long crc;
119
+ unsigned long total;
120
+ };
121
+
122
+ /* Write output buffer and update the CRC-32 and total bytes written. write()
123
+ is called until all of the output is written or an error is encountered.
124
+ On success out() returns 0. For a write failure, out() returns 1. If the
125
+ output file descriptor is -1, then nothing is written.
126
+ */
127
+ local int out(void *out_desc, unsigned char *buf, unsigned len)
128
+ {
129
+ int ret;
130
+ struct outd *me = (struct outd *)out_desc;
131
+
132
+ if (me->check) {
133
+ me->crc = crc32(me->crc, buf, len);
134
+ me->total += len;
135
+ }
136
+ if (me->outfile != -1)
137
+ do {
138
+ ret = PIECE;
139
+ if ((unsigned)ret > len)
140
+ ret = (int)len;
141
+ ret = (int)write(me->outfile, buf, ret);
142
+ if (ret == -1)
143
+ return 1;
144
+ buf += ret;
145
+ len -= ret;
146
+ } while (len != 0);
147
+ return 0;
148
+ }
149
+
150
+ /* next input byte macro for use inside lunpipe() and gunpipe() */
151
+ #define NEXT() (have ? 0 : (have = in(indp, &next)), \
152
+ last = have ? (have--, (int)(*next++)) : -1)
153
+
154
+ /* memory for gunpipe() and lunpipe() --
155
+ the first 256 entries of prefix[] and suffix[] are never used, could
156
+ have offset the index, but it's faster to waste the memory */
157
+ unsigned char inbuf[SIZE]; /* input buffer */
158
+ unsigned char outbuf[SIZE]; /* output buffer */
159
+ unsigned short prefix[65536]; /* index to LZW prefix string */
160
+ unsigned char suffix[65536]; /* one-character LZW suffix */
161
+ unsigned char match[65280 + 2]; /* buffer for reversed match or gzip
162
+ 32K sliding window */
163
+
164
+ /* throw out what's left in the current bits byte buffer (this is a vestigial
165
+ aspect of the compressed data format derived from an implementation that
166
+ made use of a special VAX machine instruction!) */
167
+ #define FLUSHCODE() \
168
+ do { \
169
+ left = 0; \
170
+ rem = 0; \
171
+ if (chunk > have) { \
172
+ chunk -= have; \
173
+ have = 0; \
174
+ if (NEXT() == -1) \
175
+ break; \
176
+ chunk--; \
177
+ if (chunk > have) { \
178
+ chunk = have = 0; \
179
+ break; \
180
+ } \
181
+ } \
182
+ have -= chunk; \
183
+ next += chunk; \
184
+ chunk = 0; \
185
+ } while (0)
186
+
187
+ /* Decompress a compress (LZW) file from indp to outfile. The compress magic
188
+ header (two bytes) has already been read and verified. There are have bytes
189
+ of buffered input at next. strm is used for passing error information back
190
+ to gunpipe().
191
+
192
+ lunpipe() will return Z_OK on success, Z_BUF_ERROR for an unexpected end of
193
+ file, read error, or write error (a write error indicated by strm->next_in
194
+ not equal to Z_NULL), or Z_DATA_ERROR for invalid input.
195
+ */
196
+ local int lunpipe(unsigned have, unsigned char *next, struct ind *indp,
197
+ int outfile, z_stream *strm)
198
+ {
199
+ int last; /* last byte read by NEXT(), or -1 if EOF */
200
+ int chunk; /* bytes left in current chunk */
201
+ int left; /* bits left in rem */
202
+ unsigned rem; /* unused bits from input */
203
+ int bits; /* current bits per code */
204
+ unsigned code; /* code, table traversal index */
205
+ unsigned mask; /* mask for current bits codes */
206
+ int max; /* maximum bits per code for this stream */
207
+ int flags; /* compress flags, then block compress flag */
208
+ unsigned end; /* last valid entry in prefix/suffix tables */
209
+ unsigned temp; /* current code */
210
+ unsigned prev; /* previous code */
211
+ unsigned final; /* last character written for previous code */
212
+ unsigned stack; /* next position for reversed string */
213
+ unsigned outcnt; /* bytes in output buffer */
214
+ struct outd outd; /* output structure */
215
+
216
+ /* set up output */
217
+ outd.outfile = outfile;
218
+ outd.check = 0;
219
+
220
+ /* process remainder of compress header -- a flags byte */
221
+ flags = NEXT();
222
+ if (last == -1)
223
+ return Z_BUF_ERROR;
224
+ if (flags & 0x60) {
225
+ strm->msg = (char *)"unknown lzw flags set";
226
+ return Z_DATA_ERROR;
227
+ }
228
+ max = flags & 0x1f;
229
+ if (max < 9 || max > 16) {
230
+ strm->msg = (char *)"lzw bits out of range";
231
+ return Z_DATA_ERROR;
232
+ }
233
+ if (max == 9) /* 9 doesn't really mean 9 */
234
+ max = 10;
235
+ flags &= 0x80; /* true if block compress */
236
+
237
+ /* clear table */
238
+ bits = 9;
239
+ mask = 0x1ff;
240
+ end = flags ? 256 : 255;
241
+
242
+ /* set up: get first 9-bit code, which is the first decompressed byte, but
243
+ don't create a table entry until the next code */
244
+ if (NEXT() == -1) /* no compressed data is ok */
245
+ return Z_OK;
246
+ final = prev = (unsigned)last; /* low 8 bits of code */
247
+ if (NEXT() == -1) /* missing a bit */
248
+ return Z_BUF_ERROR;
249
+ if (last & 1) { /* code must be < 256 */
250
+ strm->msg = (char *)"invalid lzw code";
251
+ return Z_DATA_ERROR;
252
+ }
253
+ rem = (unsigned)last >> 1; /* remaining 7 bits */
254
+ left = 7;
255
+ chunk = bits - 2; /* 7 bytes left in this chunk */
256
+ outbuf[0] = (unsigned char)final; /* write first decompressed byte */
257
+ outcnt = 1;
258
+
259
+ /* decode codes */
260
+ stack = 0;
261
+ for (;;) {
262
+ /* if the table will be full after this, increment the code size */
263
+ if (end >= mask && bits < max) {
264
+ FLUSHCODE();
265
+ bits++;
266
+ mask <<= 1;
267
+ mask++;
268
+ }
269
+
270
+ /* get a code of length bits */
271
+ if (chunk == 0) /* decrement chunk modulo bits */
272
+ chunk = bits;
273
+ code = rem; /* low bits of code */
274
+ if (NEXT() == -1) { /* EOF is end of compressed data */
275
+ /* write remaining buffered output */
276
+ if (outcnt && out(&outd, outbuf, outcnt)) {
277
+ strm->next_in = outbuf; /* signal write error */
278
+ return Z_BUF_ERROR;
279
+ }
280
+ return Z_OK;
281
+ }
282
+ code += (unsigned)last << left; /* middle (or high) bits of code */
283
+ left += 8;
284
+ chunk--;
285
+ if (bits > left) { /* need more bits */
286
+ if (NEXT() == -1) /* can't end in middle of code */
287
+ return Z_BUF_ERROR;
288
+ code += (unsigned)last << left; /* high bits of code */
289
+ left += 8;
290
+ chunk--;
291
+ }
292
+ code &= mask; /* mask to current code length */
293
+ left -= bits; /* number of unused bits */
294
+ rem = (unsigned)last >> (8 - left); /* unused bits from last byte */
295
+
296
+ /* process clear code (256) */
297
+ if (code == 256 && flags) {
298
+ FLUSHCODE();
299
+ bits = 9; /* initialize bits and mask */
300
+ mask = 0x1ff;
301
+ end = 255; /* empty table */
302
+ continue; /* get next code */
303
+ }
304
+
305
+ /* special code to reuse last match */
306
+ temp = code; /* save the current code */
307
+ if (code > end) {
308
+ /* Be picky on the allowed code here, and make sure that the code
309
+ we drop through (prev) will be a valid index so that random
310
+ input does not cause an exception. The code != end + 1 check is
311
+ empirically derived, and not checked in the original uncompress
312
+ code. If this ever causes a problem, that check could be safely
313
+ removed. Leaving this check in greatly improves gun's ability
314
+ to detect random or corrupted input after a compress header.
315
+ In any case, the prev > end check must be retained. */
316
+ if (code != end + 1 || prev > end) {
317
+ strm->msg = (char *)"invalid lzw code";
318
+ return Z_DATA_ERROR;
319
+ }
320
+ match[stack++] = (unsigned char)final;
321
+ code = prev;
322
+ }
323
+
324
+ /* walk through linked list to generate output in reverse order */
325
+ while (code >= 256) {
326
+ match[stack++] = suffix[code];
327
+ code = prefix[code];
328
+ }
329
+ match[stack++] = (unsigned char)code;
330
+ final = code;
331
+
332
+ /* link new table entry */
333
+ if (end < mask) {
334
+ end++;
335
+ prefix[end] = (unsigned short)prev;
336
+ suffix[end] = (unsigned char)final;
337
+ }
338
+
339
+ /* set previous code for next iteration */
340
+ prev = temp;
341
+
342
+ /* write output in forward order */
343
+ while (stack > SIZE - outcnt) {
344
+ while (outcnt < SIZE)
345
+ outbuf[outcnt++] = match[--stack];
346
+ if (out(&outd, outbuf, outcnt)) {
347
+ strm->next_in = outbuf; /* signal write error */
348
+ return Z_BUF_ERROR;
349
+ }
350
+ outcnt = 0;
351
+ }
352
+ do {
353
+ outbuf[outcnt++] = match[--stack];
354
+ } while (stack);
355
+
356
+ /* loop for next code with final and prev as the last match, rem and
357
+ left provide the first 0..7 bits of the next code, end is the last
358
+ valid table entry */
359
+ }
360
+ }
361
+
362
+ /* Decompress a gzip file from infile to outfile. strm is assumed to have been
363
+ successfully initialized with inflateBackInit(). The input file may consist
364
+ of a series of gzip streams, in which case all of them will be decompressed
365
+ to the output file. If outfile is -1, then the gzip stream(s) integrity is
366
+ checked and nothing is written.
367
+
368
+ The return value is a zlib error code: Z_MEM_ERROR if out of memory,
369
+ Z_DATA_ERROR if the header or the compressed data is invalid, or if the
370
+ trailer CRC-32 check or length doesn't match, Z_BUF_ERROR if the input ends
371
+ prematurely or a write error occurs, or Z_ERRNO if junk (not a another gzip
372
+ stream) follows a valid gzip stream.
373
+ */
374
+ local int gunpipe(z_stream *strm, int infile, int outfile)
375
+ {
376
+ int ret, first, last;
377
+ unsigned have, flags, len;
378
+ unsigned char *next;
379
+ struct ind ind, *indp;
380
+ struct outd outd;
381
+
382
+ /* setup input buffer */
383
+ ind.infile = infile;
384
+ ind.inbuf = inbuf;
385
+ indp = &ind;
386
+
387
+ /* decompress concatenated gzip streams */
388
+ have = 0; /* no input data read in yet */
389
+ first = 1; /* looking for first gzip header */
390
+ strm->next_in = Z_NULL; /* so Z_BUF_ERROR means EOF */
391
+ for (;;) {
392
+ /* look for the two magic header bytes for a gzip stream */
393
+ if (NEXT() == -1) {
394
+ ret = Z_OK;
395
+ break; /* empty gzip stream is ok */
396
+ }
397
+ if (last != 31 || (NEXT() != 139 && last != 157)) {
398
+ strm->msg = (char *)"incorrect header check";
399
+ ret = first ? Z_DATA_ERROR : Z_ERRNO;
400
+ break; /* not a gzip or compress header */
401
+ }
402
+ first = 0; /* next non-header is junk */
403
+
404
+ /* process a compress (LZW) file -- can't be concatenated after this */
405
+ if (last == 157) {
406
+ ret = lunpipe(have, next, indp, outfile, strm);
407
+ break;
408
+ }
409
+
410
+ /* process remainder of gzip header */
411
+ ret = Z_BUF_ERROR;
412
+ if (NEXT() != 8) { /* only deflate method allowed */
413
+ if (last == -1) break;
414
+ strm->msg = (char *)"unknown compression method";
415
+ ret = Z_DATA_ERROR;
416
+ break;
417
+ }
418
+ flags = NEXT(); /* header flags */
419
+ NEXT(); /* discard mod time, xflgs, os */
420
+ NEXT();
421
+ NEXT();
422
+ NEXT();
423
+ NEXT();
424
+ NEXT();
425
+ if (last == -1) break;
426
+ if (flags & 0xe0) {
427
+ strm->msg = (char *)"unknown header flags set";
428
+ ret = Z_DATA_ERROR;
429
+ break;
430
+ }
431
+ if (flags & 4) { /* extra field */
432
+ len = NEXT();
433
+ len += (unsigned)(NEXT()) << 8;
434
+ if (last == -1) break;
435
+ while (len > have) {
436
+ len -= have;
437
+ have = 0;
438
+ if (NEXT() == -1) break;
439
+ len--;
440
+ }
441
+ if (last == -1) break;
442
+ have -= len;
443
+ next += len;
444
+ }
445
+ if (flags & 8) /* file name */
446
+ while (NEXT() != 0 && last != -1)
447
+ ;
448
+ if (flags & 16) /* comment */
449
+ while (NEXT() != 0 && last != -1)
450
+ ;
451
+ if (flags & 2) { /* header crc */
452
+ NEXT();
453
+ NEXT();
454
+ }
455
+ if (last == -1) break;
456
+
457
+ /* set up output */
458
+ outd.outfile = outfile;
459
+ outd.check = 1;
460
+ outd.crc = crc32(0L, Z_NULL, 0);
461
+ outd.total = 0;
462
+
463
+ /* decompress data to output */
464
+ strm->next_in = next;
465
+ strm->avail_in = have;
466
+ ret = inflateBack(strm, in, indp, out, &outd);
467
+ if (ret != Z_STREAM_END) break;
468
+ next = strm->next_in;
469
+ have = strm->avail_in;
470
+ strm->next_in = Z_NULL; /* so Z_BUF_ERROR means EOF */
471
+
472
+ /* check trailer */
473
+ ret = Z_BUF_ERROR;
474
+ if (NEXT() != (outd.crc & 0xff) ||
475
+ NEXT() != ((outd.crc >> 8) & 0xff) ||
476
+ NEXT() != ((outd.crc >> 16) & 0xff) ||
477
+ NEXT() != ((outd.crc >> 24) & 0xff)) {
478
+ /* crc error */
479
+ if (last != -1) {
480
+ strm->msg = (char *)"incorrect data check";
481
+ ret = Z_DATA_ERROR;
482
+ }
483
+ break;
484
+ }
485
+ if (NEXT() != (outd.total & 0xff) ||
486
+ NEXT() != ((outd.total >> 8) & 0xff) ||
487
+ NEXT() != ((outd.total >> 16) & 0xff) ||
488
+ NEXT() != ((outd.total >> 24) & 0xff)) {
489
+ /* length error */
490
+ if (last != -1) {
491
+ strm->msg = (char *)"incorrect length check";
492
+ ret = Z_DATA_ERROR;
493
+ }
494
+ break;
495
+ }
496
+
497
+ /* go back and look for another gzip stream */
498
+ }
499
+
500
+ /* clean up and return */
501
+ return ret;
502
+ }
503
+
504
+ /* Copy file attributes, from -> to, as best we can. This is best effort, so
505
+ no errors are reported. The mode bits, including suid, sgid, and the sticky
506
+ bit are copied (if allowed), the owner's user id and group id are copied
507
+ (again if allowed), and the access and modify times are copied. */
508
+ local void copymeta(char *from, char *to)
509
+ {
510
+ struct stat was;
511
+ struct utimbuf when;
512
+
513
+ /* get all of from's Unix meta data, return if not a regular file */
514
+ if (stat(from, &was) != 0 || (was.st_mode & S_IFMT) != S_IFREG)
515
+ return;
516
+
517
+ /* set to's mode bits, ignore errors */
518
+ (void)chmod(to, was.st_mode & 07777);
519
+
520
+ /* copy owner's user and group, ignore errors */
521
+ (void)chown(to, was.st_uid, was.st_gid);
522
+
523
+ /* copy access and modify times, ignore errors */
524
+ when.actime = was.st_atime;
525
+ when.modtime = was.st_mtime;
526
+ (void)utime(to, &when);
527
+ }
528
+
529
+ /* Decompress the file inname to the file outnname, of if test is true, just
530
+ decompress without writing and check the gzip trailer for integrity. If
531
+ inname is NULL or an empty string, read from stdin. If outname is NULL or
532
+ an empty string, write to stdout. strm is a pre-initialized inflateBack
533
+ structure. When appropriate, copy the file attributes from inname to
534
+ outname.
535
+
536
+ gunzip() returns 1 if there is an out-of-memory error or an unexpected
537
+ return code from gunpipe(). Otherwise it returns 0.
538
+ */
539
+ local int gunzip(z_stream *strm, char *inname, char *outname, int test)
540
+ {
541
+ int ret;
542
+ int infile, outfile;
543
+
544
+ /* open files */
545
+ if (inname == NULL || *inname == 0) {
546
+ inname = "-";
547
+ infile = 0; /* stdin */
548
+ }
549
+ else {
550
+ infile = open(inname, O_RDONLY, 0);
551
+ if (infile == -1) {
552
+ fprintf(stderr, "gun cannot open %s\n", inname);
553
+ return 0;
554
+ }
555
+ }
556
+ if (test)
557
+ outfile = -1;
558
+ else if (outname == NULL || *outname == 0) {
559
+ outname = "-";
560
+ outfile = 1; /* stdout */
561
+ }
562
+ else {
563
+ outfile = open(outname, O_CREAT | O_TRUNC | O_WRONLY, 0666);
564
+ if (outfile == -1) {
565
+ close(infile);
566
+ fprintf(stderr, "gun cannot create %s\n", outname);
567
+ return 0;
568
+ }
569
+ }
570
+ errno = 0;
571
+
572
+ /* decompress */
573
+ ret = gunpipe(strm, infile, outfile);
574
+ if (outfile > 2) close(outfile);
575
+ if (infile > 2) close(infile);
576
+
577
+ /* interpret result */
578
+ switch (ret) {
579
+ case Z_OK:
580
+ case Z_ERRNO:
581
+ if (infile > 2 && outfile > 2) {
582
+ copymeta(inname, outname); /* copy attributes */
583
+ unlink(inname);
584
+ }
585
+ if (ret == Z_ERRNO)
586
+ fprintf(stderr, "gun warning: trailing garbage ignored in %s\n",
587
+ inname);
588
+ break;
589
+ case Z_DATA_ERROR:
590
+ if (outfile > 2) unlink(outname);
591
+ fprintf(stderr, "gun data error on %s: %s\n", inname, strm->msg);
592
+ break;
593
+ case Z_MEM_ERROR:
594
+ if (outfile > 2) unlink(outname);
595
+ fprintf(stderr, "gun out of memory error--aborting\n");
596
+ return 1;
597
+ case Z_BUF_ERROR:
598
+ if (outfile > 2) unlink(outname);
599
+ if (strm->next_in != Z_NULL) {
600
+ fprintf(stderr, "gun write error on %s: %s\n",
601
+ outname, strerror(errno));
602
+ }
603
+ else if (errno) {
604
+ fprintf(stderr, "gun read error on %s: %s\n",
605
+ inname, strerror(errno));
606
+ }
607
+ else {
608
+ fprintf(stderr, "gun unexpected end of file on %s\n",
609
+ inname);
610
+ }
611
+ break;
612
+ default:
613
+ if (outfile > 2) unlink(outname);
614
+ fprintf(stderr, "gun internal error--aborting\n");
615
+ return 1;
616
+ }
617
+ return 0;
618
+ }
619
+
620
+ /* Process the gun command line arguments. See the command syntax near the
621
+ beginning of this source file. */
622
+ int main(int argc, char **argv)
623
+ {
624
+ int ret, len, test;
625
+ char *outname;
626
+ unsigned char *window;
627
+ z_stream strm;
628
+
629
+ /* initialize inflateBack state for repeated use */
630
+ window = match; /* reuse LZW match buffer */
631
+ strm.zalloc = Z_NULL;
632
+ strm.zfree = Z_NULL;
633
+ strm.opaque = Z_NULL;
634
+ ret = inflateBackInit(&strm, 15, window);
635
+ if (ret != Z_OK) {
636
+ fprintf(stderr, "gun out of memory error--aborting\n");
637
+ return 1;
638
+ }
639
+
640
+ /* decompress each file to the same name with the suffix removed */
641
+ argc--;
642
+ argv++;
643
+ test = 0;
644
+ if (argc && strcmp(*argv, "-h") == 0) {
645
+ fprintf(stderr, "gun 1.3 (12 Jun 2005)\n");
646
+ fprintf(stderr, "Copyright (c) 2005 Mark Adler\n");
647
+ fprintf(stderr, "usage: gun [-t] [file1.gz [file2.Z ...]]\n");
648
+ return 0;
649
+ }
650
+ if (argc && strcmp(*argv, "-t") == 0) {
651
+ test = 1;
652
+ argc--;
653
+ argv++;
654
+ }
655
+ if (argc)
656
+ do {
657
+ if (test)
658
+ outname = NULL;
659
+ else {
660
+ len = (int)strlen(*argv);
661
+ if (strcmp(*argv + len - 3, ".gz") == 0 ||
662
+ strcmp(*argv + len - 3, "-gz") == 0)
663
+ len -= 3;
664
+ else if (strcmp(*argv + len - 2, ".z") == 0 ||
665
+ strcmp(*argv + len - 2, "-z") == 0 ||
666
+ strcmp(*argv + len - 2, "_z") == 0 ||
667
+ strcmp(*argv + len - 2, ".Z") == 0)
668
+ len -= 2;
669
+ else {
670
+ fprintf(stderr, "gun error: no gz type on %s--skipping\n",
671
+ *argv);
672
+ continue;
673
+ }
674
+ outname = malloc(len + 1);
675
+ if (outname == NULL) {
676
+ fprintf(stderr, "gun out of memory error--aborting\n");
677
+ ret = 1;
678
+ break;
679
+ }
680
+ memcpy(outname, *argv, len);
681
+ outname[len] = 0;
682
+ }
683
+ ret = gunzip(&strm, *argv, outname, test);
684
+ if (outname != NULL) free(outname);
685
+ if (ret) break;
686
+ } while (argv++, --argc);
687
+ else
688
+ ret = gunzip(&strm, NULL, NULL, test);
689
+
690
+ /* clean up */
691
+ inflateBackEnd(&strm);
692
+ return ret;
693
+ }