rhodes 3.3.5 → 3.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (1678) hide show
  1. data/CHANGELOG +3 -1
  2. data/CREDITS +5 -0
  3. data/Rakefile +173 -17
  4. data/doc/build.txt +71 -27
  5. data/doc/configuration.txt +2 -0
  6. data/doc/device-caps.txt +103 -27
  7. data/doc/extensions.txt +49 -33
  8. data/doc/install.txt +15 -12
  9. data/doc/introduction.txt +1 -1
  10. data/doc/nfc.txt +3 -2
  11. data/doc/rhom.txt +22 -1
  12. data/doc/{rhostudio-eclipse.txt → rhostudio-eclipse_outdated.txt} +0 -0
  13. data/doc/rhostudio-test-plan.txt +79 -22
  14. data/doc/simulator.txt +19 -52
  15. data/doc/standard-css.txt +1 -1
  16. data/doc/synchronization.txt +2 -0
  17. data/doc/test-log-debug.txt +149 -1
  18. data/doc/ui.txt +57 -0
  19. data/lib/build/jake.rb +33 -22
  20. data/lib/extensions/barcode/ext/barcode/platform/iphone/Barcode.xcodeproj/project.pbxproj +4 -10
  21. data/lib/extensions/debugger/debugger.rb +18 -5
  22. data/lib/extensions/digest-md5/digest/md5.rb +0 -0
  23. data/lib/extensions/digest-md5/ext/iphone/Dmd5.xcodeproj/project.pbxproj +4 -10
  24. data/lib/extensions/digest-sha1/digest/sha1.rb +0 -0
  25. data/lib/extensions/digest-sha1/ext/iphone/Dsha1.xcodeproj/project.pbxproj +4 -10
  26. data/lib/extensions/digest-sha2/digest/sha2.rb +0 -0
  27. data/lib/extensions/digest-sha2/ext.yml +2 -0
  28. data/lib/extensions/digest-sha2/ext/Rakefile +128 -0
  29. data/lib/extensions/digest-sha2/ext/build +12 -0
  30. data/lib/extensions/digest-sha2/ext/build.bat +1 -0
  31. data/lib/extensions/digest-sha2/ext/depend +6 -0
  32. data/lib/extensions/digest-sha2/ext/digest-sha2.sln +44 -0
  33. data/lib/extensions/digest-sha2/ext/digest-sha2.vcproj +666 -0
  34. data/lib/extensions/digest-sha2/ext/extconf.rb +27 -0
  35. data/lib/extensions/digest-sha2/ext/iphone/Dsha2.xcodeproj/project.pbxproj +272 -0
  36. data/lib/extensions/digest-sha2/ext/iphone/Dsha2_Prefix.pch +7 -0
  37. data/lib/extensions/digest-sha2/ext/iphone/Rakefile +79 -0
  38. data/lib/extensions/digest-sha2/ext/sha2.c +1070 -0
  39. data/lib/extensions/digest-sha2/ext/sha2.h +225 -0
  40. data/lib/extensions/digest-sha2/ext/sha2.rb +1 -0
  41. data/lib/extensions/digest-sha2/ext/sha2init.c +56 -0
  42. data/lib/extensions/digest-sha2/ext/sha2ossl.c +11 -0
  43. data/lib/extensions/digest-sha2/ext/sha2ossl.h +17 -0
  44. data/lib/extensions/digest-sha2/sha2/sha2.rb +74 -0
  45. data/lib/extensions/digest/digest.so.rb +0 -0
  46. data/lib/extensions/digest/ext/iphone/Digest.xcodeproj/project.pbxproj +4 -10
  47. data/lib/extensions/esri/ext/esri/platform/iphone/ESRI.xcodeproj/project.pbxproj +4 -10
  48. data/lib/extensions/ezcrypto/ext/CHANGELOG +85 -0
  49. data/lib/extensions/ezcrypto/ext/MIT-LICENSE +21 -0
  50. data/lib/extensions/ezcrypto/ext/README.rdoc +152 -0
  51. data/lib/extensions/ezcrypto/ext/README_ACTIVE_CRYPTO +122 -0
  52. data/lib/extensions/ezcrypto/ext/README_DIGITAL_SIGNATURES +55 -0
  53. data/lib/extensions/ezcrypto/ext/rakefile +200 -0
  54. data/lib/extensions/ezcrypto/ext/test/active_crypto_test.rb +211 -0
  55. data/lib/extensions/ezcrypto/ext/test/agree2.com.cert +31 -0
  56. data/lib/extensions/ezcrypto/ext/test/association_key_holder_test.rb +38 -0
  57. data/lib/extensions/ezcrypto/ext/test/database.yml +18 -0
  58. data/lib/extensions/ezcrypto/ext/test/digest_test.rb +51 -0
  59. data/lib/extensions/ezcrypto/ext/test/dsakey.pem +12 -0
  60. data/lib/extensions/ezcrypto/ext/test/dsapubkey.pem +12 -0
  61. data/lib/extensions/ezcrypto/ext/test/dsig_test.rb +288 -0
  62. data/lib/extensions/ezcrypto/ext/test/encrypt_test.rb +41 -0
  63. data/lib/extensions/ezcrypto/ext/test/ezcrypto_test.rb +212 -0
  64. data/lib/extensions/ezcrypto/ext/test/key_holder_test.rb +44 -0
  65. data/lib/extensions/ezcrypto/ext/test/protectedsigner.pem +12 -0
  66. data/lib/extensions/ezcrypto/ext/test/sf-class2-root.crt +24 -0
  67. data/lib/extensions/ezcrypto/ext/test/sf_intermediate.crt +29 -0
  68. data/lib/extensions/ezcrypto/ext/test/test_helper.rb +35 -0
  69. data/lib/extensions/ezcrypto/ext/test/testchild.pem +15 -0
  70. data/lib/extensions/ezcrypto/ext/test/testchild.req +12 -0
  71. data/lib/extensions/ezcrypto/ext/test/testpub.pem +4 -0
  72. data/lib/extensions/ezcrypto/ext/test/testsigner.cert +20 -0
  73. data/lib/extensions/ezcrypto/ext/test/testsigner.pem +9 -0
  74. data/lib/extensions/ezcrypto/ext/test/valicert_class2_root.crt +18 -0
  75. data/lib/extensions/ezcrypto/ezcrypto.rb +1 -0
  76. data/lib/extensions/ezcrypto/ezcrypto/ezcrypto.rb +612 -0
  77. data/lib/extensions/ezcrypto/ezcrypto/ezsig.rb +535 -0
  78. data/lib/extensions/ezcrypto/ezcrypto/trusted.pem +2363 -0
  79. data/lib/extensions/fcntl/ext/iphone/Fcntl.xcodeproj/project.pbxproj +4 -10
  80. data/lib/extensions/fcntl/fcntl.rb +0 -0
  81. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/Nfc.java +9 -22
  82. data/lib/extensions/openssl.so.src/ext.yml +2 -0
  83. data/lib/extensions/openssl.so.src/ext/Rakefile +107 -0
  84. data/lib/extensions/openssl.so.src/ext/build +12 -0
  85. data/lib/extensions/openssl.so.src/ext/build.bat +1 -0
  86. data/lib/extensions/openssl.so/ext.yml +9 -0
  87. data/lib/extensions/openssl.so/ext/Rakefile +139 -0
  88. data/lib/extensions/openssl.so/ext/android/libopenssl.so.a +0 -0
  89. data/lib/extensions/openssl.so/ext/build +12 -0
  90. data/lib/extensions/openssl.so/ext/build.bat +1 -0
  91. data/lib/extensions/openssl.so/ext/iphone/Rakefile +79 -0
  92. data/lib/extensions/openssl.so/ext/iphone/Release-iphoneos/libopenssl.so.a +0 -0
  93. data/lib/extensions/openssl.so/ext/iphone/Release-iphonesimulator/libopenssl.so.a +0 -0
  94. data/lib/extensions/openssl.so/ext/iphone/openssl/openssl.xcodeproj/project.pbxproj +4300 -0
  95. data/lib/extensions/openssl.so/ext/iphone/openssl/openssl/openssl-Prefix.pch +7 -0
  96. data/lib/extensions/openssl.so/ext/sources/apps/apps.h +373 -0
  97. data/lib/extensions/openssl.so/ext/sources/apps/progs.h +366 -0
  98. data/lib/extensions/openssl.so/ext/sources/apps/s_apps.h +176 -0
  99. data/lib/extensions/openssl.so/ext/sources/apps/testdsa.h +217 -0
  100. data/lib/extensions/openssl.so/ext/sources/apps/testrsa.h +518 -0
  101. data/lib/extensions/openssl.so/ext/sources/crypto/LPdir_unix.c +127 -0
  102. data/lib/extensions/openssl.so/ext/sources/crypto/LPdir_win.c +153 -0
  103. data/lib/extensions/openssl.so/ext/sources/crypto/LPdir_win32.c +30 -0
  104. data/lib/extensions/openssl.so/ext/sources/crypto/aes/aes.h +147 -0
  105. data/lib/extensions/openssl.so/ext/sources/crypto/aes/aes_cbc.c +63 -0
  106. data/lib/extensions/openssl.so/ext/sources/crypto/aes/aes_cfb.c +81 -0
  107. data/lib/extensions/openssl.so/ext/sources/crypto/aes/aes_core.c +1358 -0
  108. data/lib/extensions/openssl.so/ext/sources/crypto/aes/aes_ctr.c +61 -0
  109. data/lib/extensions/openssl.so/ext/sources/crypto/aes/aes_ecb.c +73 -0
  110. data/lib/extensions/openssl.so/ext/sources/crypto/aes/aes_ige.c +323 -0
  111. data/lib/extensions/openssl.so/ext/sources/crypto/aes/aes_locl.h +89 -0
  112. data/lib/extensions/openssl.so/ext/sources/crypto/aes/aes_misc.c +85 -0
  113. data/lib/extensions/openssl.so/ext/sources/crypto/aes/aes_ofb.c +60 -0
  114. data/lib/extensions/openssl.so/ext/sources/crypto/aes/aes_wrap.c +259 -0
  115. data/lib/extensions/openssl.so/ext/sources/crypto/arm_arch.h +51 -0
  116. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/a_bitstr.c +248 -0
  117. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/a_bool.c +114 -0
  118. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/a_bytes.c +314 -0
  119. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/a_d2i_fp.c +286 -0
  120. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/a_digest.c +113 -0
  121. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/a_dup.c +109 -0
  122. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/a_enum.c +182 -0
  123. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/a_gentm.c +263 -0
  124. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/a_i2d_fp.c +163 -0
  125. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/a_int.c +458 -0
  126. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/a_mbstr.c +400 -0
  127. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/a_object.c +403 -0
  128. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/a_octet.c +71 -0
  129. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/a_print.c +127 -0
  130. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/a_set.c +241 -0
  131. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/a_sign.c +333 -0
  132. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/a_strex.c +574 -0
  133. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/a_strnid.c +290 -0
  134. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/a_time.c +198 -0
  135. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/a_type.c +159 -0
  136. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/a_utctm.c +318 -0
  137. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/a_utf8.c +211 -0
  138. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/a_verify.c +228 -0
  139. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/ameth_lib.c +460 -0
  140. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/asn1.h +1404 -0
  141. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/asn1_err.c +332 -0
  142. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/asn1_gen.c +854 -0
  143. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/asn1_lib.c +482 -0
  144. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/asn1_locl.h +145 -0
  145. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/asn1_mac.h +578 -0
  146. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/asn1_par.c +437 -0
  147. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/asn1t.h +960 -0
  148. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/asn_mime.c +951 -0
  149. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/asn_moid.c +160 -0
  150. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/asn_pack.c +191 -0
  151. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/bio_asn1.c +495 -0
  152. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/bio_ndef.c +243 -0
  153. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/charmap.h +15 -0
  154. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/d2i_pr.c +170 -0
  155. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/d2i_pu.c +139 -0
  156. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/evp_asn1.c +189 -0
  157. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/f_enum.c +207 -0
  158. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/f_int.c +219 -0
  159. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/f_string.c +212 -0
  160. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/i2d_pr.c +80 -0
  161. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/i2d_pu.c +95 -0
  162. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/n_pkey.c +357 -0
  163. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/nsseq.c +83 -0
  164. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/p5_pbe.c +148 -0
  165. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/p5_pbev2.c +280 -0
  166. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/p8_pkey.c +155 -0
  167. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/t_bitst.c +102 -0
  168. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/t_crl.c +132 -0
  169. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/t_pkey.c +114 -0
  170. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/t_req.c +266 -0
  171. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/t_spki.c +107 -0
  172. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/t_x509.c +528 -0
  173. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/t_x509a.c +110 -0
  174. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/tasn_dec.c +1347 -0
  175. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/tasn_enc.c +691 -0
  176. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/tasn_fre.c +266 -0
  177. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/tasn_new.c +396 -0
  178. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/tasn_prn.c +627 -0
  179. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/tasn_typ.c +148 -0
  180. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/tasn_utl.c +279 -0
  181. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/x_algor.c +144 -0
  182. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/x_attrib.c +118 -0
  183. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/x_bignum.c +139 -0
  184. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/x_crl.c +527 -0
  185. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/x_exten.c +76 -0
  186. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/x_info.c +114 -0
  187. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/x_long.c +179 -0
  188. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/x_name.c +519 -0
  189. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/x_nx509.c +72 -0
  190. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/x_pkey.c +151 -0
  191. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/x_pubkey.c +382 -0
  192. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/x_req.c +113 -0
  193. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/x_sig.c +69 -0
  194. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/x_spki.c +81 -0
  195. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/x_val.c +69 -0
  196. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/x_x509.c +194 -0
  197. data/lib/extensions/openssl.so/ext/sources/crypto/asn1/x_x509a.c +180 -0
  198. data/lib/extensions/openssl.so/ext/sources/crypto/bf/bf_cfb64.c +121 -0
  199. data/lib/extensions/openssl.so/ext/sources/crypto/bf/bf_ecb.c +96 -0
  200. data/lib/extensions/openssl.so/ext/sources/crypto/bf/bf_enc.c +306 -0
  201. data/lib/extensions/openssl.so/ext/sources/crypto/bf/bf_locl.h +219 -0
  202. data/lib/extensions/openssl.so/ext/sources/crypto/bf/bf_ofb64.c +110 -0
  203. data/lib/extensions/openssl.so/ext/sources/crypto/bf/bf_pi.h +325 -0
  204. data/lib/extensions/openssl.so/ext/sources/crypto/bf/bf_skey.c +124 -0
  205. data/lib/extensions/openssl.so/ext/sources/crypto/bf/blowfish.h +129 -0
  206. data/lib/extensions/openssl.so/ext/sources/crypto/bio/b_dump.c +187 -0
  207. data/lib/extensions/openssl.so/ext/sources/crypto/bio/b_print.c +842 -0
  208. data/lib/extensions/openssl.so/ext/sources/crypto/bio/b_sock.c +975 -0
  209. data/lib/extensions/openssl.so/ext/sources/crypto/bio/bf_buff.c +512 -0
  210. data/lib/extensions/openssl.so/ext/sources/crypto/bio/bf_nbio.c +253 -0
  211. data/lib/extensions/openssl.so/ext/sources/crypto/bio/bf_null.c +183 -0
  212. data/lib/extensions/openssl.so/ext/sources/crypto/bio/bio.h +847 -0
  213. data/lib/extensions/openssl.so/ext/sources/crypto/bio/bio_cb.c +143 -0
  214. data/lib/extensions/openssl.so/ext/sources/crypto/bio/bio_err.c +155 -0
  215. data/lib/extensions/openssl.so/ext/sources/crypto/bio/bio_lcl.h +36 -0
  216. data/lib/extensions/openssl.so/ext/sources/crypto/bio/bio_lib.c +602 -0
  217. data/lib/extensions/openssl.so/ext/sources/crypto/bio/bss_acpt.c +478 -0
  218. data/lib/extensions/openssl.so/ext/sources/crypto/bio/bss_bio.c +924 -0
  219. data/lib/extensions/openssl.so/ext/sources/crypto/bio/bss_conn.c +652 -0
  220. data/lib/extensions/openssl.so/ext/sources/crypto/bio/bss_dgram.c +1832 -0
  221. data/lib/extensions/openssl.so/ext/sources/crypto/bio/bss_fd.c +319 -0
  222. data/lib/extensions/openssl.so/ext/sources/crypto/bio/bss_file.c +477 -0
  223. data/lib/extensions/openssl.so/ext/sources/crypto/bio/bss_log.c +399 -0
  224. data/lib/extensions/openssl.so/ext/sources/crypto/bio/bss_mem.c +319 -0
  225. data/lib/extensions/openssl.so/ext/sources/crypto/bio/bss_null.c +150 -0
  226. data/lib/extensions/openssl.so/ext/sources/crypto/bio/bss_sock.c +294 -0
  227. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn.h +891 -0
  228. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_add.c +313 -0
  229. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_asm.c +1030 -0
  230. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_blind.c +385 -0
  231. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_const.c +402 -0
  232. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_ctx.c +454 -0
  233. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_depr.c +112 -0
  234. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_div.c +446 -0
  235. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_err.c +150 -0
  236. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_exp.c +1097 -0
  237. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_exp2.c +312 -0
  238. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_gcd.c +654 -0
  239. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_gf2m.c +1113 -0
  240. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_kron.c +184 -0
  241. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_lcl.h +508 -0
  242. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_lib.c +826 -0
  243. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_mod.c +301 -0
  244. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_mont.c +509 -0
  245. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_mpi.c +130 -0
  246. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_mul.c +1166 -0
  247. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_nist.c +1102 -0
  248. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_prime.c +494 -0
  249. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_prime.h +327 -0
  250. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_print.c +378 -0
  251. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_rand.c +305 -0
  252. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_recp.c +234 -0
  253. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_shift.c +223 -0
  254. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_sqr.c +294 -0
  255. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_sqrt.c +393 -0
  256. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_word.c +247 -0
  257. data/lib/extensions/openssl.so/ext/sources/crypto/bn/bn_x931p.c +272 -0
  258. data/lib/extensions/openssl.so/ext/sources/crypto/buffer/buf_err.c +99 -0
  259. data/lib/extensions/openssl.so/ext/sources/crypto/buffer/buf_str.c +119 -0
  260. data/lib/extensions/openssl.so/ext/sources/crypto/buffer/buffer.c +203 -0
  261. data/lib/extensions/openssl.so/ext/sources/crypto/buffer/buffer.h +119 -0
  262. data/lib/extensions/openssl.so/ext/sources/crypto/buildinf.h +12 -0
  263. data/lib/extensions/openssl.so/ext/sources/crypto/camellia/camellia.c +582 -0
  264. data/lib/extensions/openssl.so/ext/sources/crypto/camellia/camellia.h +130 -0
  265. data/lib/extensions/openssl.so/ext/sources/crypto/camellia/cmll_cbc.c +64 -0
  266. data/lib/extensions/openssl.so/ext/sources/crypto/camellia/cmll_cfb.c +139 -0
  267. data/lib/extensions/openssl.so/ext/sources/crypto/camellia/cmll_ctr.c +64 -0
  268. data/lib/extensions/openssl.so/ext/sources/crypto/camellia/cmll_ecb.c +74 -0
  269. data/lib/extensions/openssl.so/ext/sources/crypto/camellia/cmll_locl.h +86 -0
  270. data/lib/extensions/openssl.so/ext/sources/crypto/camellia/cmll_misc.c +80 -0
  271. data/lib/extensions/openssl.so/ext/sources/crypto/camellia/cmll_ofb.c +119 -0
  272. data/lib/extensions/openssl.so/ext/sources/crypto/camellia/cmll_utl.c +64 -0
  273. data/lib/extensions/openssl.so/ext/sources/crypto/cast/c_cfb64.c +121 -0
  274. data/lib/extensions/openssl.so/ext/sources/crypto/cast/c_ecb.c +79 -0
  275. data/lib/extensions/openssl.so/ext/sources/crypto/cast/c_enc.c +208 -0
  276. data/lib/extensions/openssl.so/ext/sources/crypto/cast/c_ofb64.c +110 -0
  277. data/lib/extensions/openssl.so/ext/sources/crypto/cast/c_skey.c +173 -0
  278. data/lib/extensions/openssl.so/ext/sources/crypto/cast/cast.h +107 -0
  279. data/lib/extensions/openssl.so/ext/sources/crypto/cast/cast_lcl.h +227 -0
  280. data/lib/extensions/openssl.so/ext/sources/crypto/cast/cast_s.h +585 -0
  281. data/lib/extensions/openssl.so/ext/sources/crypto/cmac/cm_ameth.c +97 -0
  282. data/lib/extensions/openssl.so/ext/sources/crypto/cmac/cm_pmeth.c +224 -0
  283. data/lib/extensions/openssl.so/ext/sources/crypto/cmac/cmac.c +308 -0
  284. data/lib/extensions/openssl.so/ext/sources/crypto/cmac/cmac.h +82 -0
  285. data/lib/extensions/openssl.so/ext/sources/crypto/cms/cms.h +501 -0
  286. data/lib/extensions/openssl.so/ext/sources/crypto/cms/cms_asn1.c +389 -0
  287. data/lib/extensions/openssl.so/ext/sources/crypto/cms/cms_att.c +195 -0
  288. data/lib/extensions/openssl.so/ext/sources/crypto/cms/cms_cd.c +134 -0
  289. data/lib/extensions/openssl.so/ext/sources/crypto/cms/cms_dd.c +148 -0
  290. data/lib/extensions/openssl.so/ext/sources/crypto/cms/cms_enc.c +294 -0
  291. data/lib/extensions/openssl.so/ext/sources/crypto/cms/cms_env.c +876 -0
  292. data/lib/extensions/openssl.so/ext/sources/crypto/cms/cms_err.c +245 -0
  293. data/lib/extensions/openssl.so/ext/sources/crypto/cms/cms_ess.c +420 -0
  294. data/lib/extensions/openssl.so/ext/sources/crypto/cms/cms_io.c +133 -0
  295. data/lib/extensions/openssl.so/ext/sources/crypto/cms/cms_lcl.h +473 -0
  296. data/lib/extensions/openssl.so/ext/sources/crypto/cms/cms_lib.c +626 -0
  297. data/lib/extensions/openssl.so/ext/sources/crypto/cms/cms_pwri.c +454 -0
  298. data/lib/extensions/openssl.so/ext/sources/crypto/cms/cms_sd.c +985 -0
  299. data/lib/extensions/openssl.so/ext/sources/crypto/cms/cms_smime.c +850 -0
  300. data/lib/extensions/openssl.so/ext/sources/crypto/comp/c_rle.c +61 -0
  301. data/lib/extensions/openssl.so/ext/sources/crypto/comp/c_zlib.c +799 -0
  302. data/lib/extensions/openssl.so/ext/sources/crypto/comp/comp.h +80 -0
  303. data/lib/extensions/openssl.so/ext/sources/crypto/comp/comp_err.c +100 -0
  304. data/lib/extensions/openssl.so/ext/sources/crypto/comp/comp_lib.c +72 -0
  305. data/lib/extensions/openssl.so/ext/sources/crypto/conf/conf.h +263 -0
  306. data/lib/extensions/openssl.so/ext/sources/crypto/conf/conf_api.c +301 -0
  307. data/lib/extensions/openssl.so/ext/sources/crypto/conf/conf_api.h +89 -0
  308. data/lib/extensions/openssl.so/ext/sources/crypto/conf/conf_def.c +740 -0
  309. data/lib/extensions/openssl.so/ext/sources/crypto/conf/conf_def.h +180 -0
  310. data/lib/extensions/openssl.so/ext/sources/crypto/conf/conf_err.c +131 -0
  311. data/lib/extensions/openssl.so/ext/sources/crypto/conf/conf_lib.c +407 -0
  312. data/lib/extensions/openssl.so/ext/sources/crypto/conf/conf_mall.c +80 -0
  313. data/lib/extensions/openssl.so/ext/sources/crypto/conf/conf_mod.c +623 -0
  314. data/lib/extensions/openssl.so/ext/sources/crypto/conf/conf_sap.c +111 -0
  315. data/lib/extensions/openssl.so/ext/sources/crypto/cpt_err.c +105 -0
  316. data/lib/extensions/openssl.so/ext/sources/crypto/cryptlib.c +926 -0
  317. data/lib/extensions/openssl.so/ext/sources/crypto/cryptlib.h +111 -0
  318. data/lib/extensions/openssl.so/ext/sources/crypto/crypto.h +604 -0
  319. data/lib/extensions/openssl.so/ext/sources/crypto/cversion.c +117 -0
  320. data/lib/extensions/openssl.so/ext/sources/crypto/des/cbc_cksm.c +106 -0
  321. data/lib/extensions/openssl.so/ext/sources/crypto/des/cbc_enc.c +61 -0
  322. data/lib/extensions/openssl.so/ext/sources/crypto/des/cfb64ede.c +254 -0
  323. data/lib/extensions/openssl.so/ext/sources/crypto/des/cfb64enc.c +121 -0
  324. data/lib/extensions/openssl.so/ext/sources/crypto/des/cfb_enc.c +195 -0
  325. data/lib/extensions/openssl.so/ext/sources/crypto/des/des.h +248 -0
  326. data/lib/extensions/openssl.so/ext/sources/crypto/des/des_enc.c +400 -0
  327. data/lib/extensions/openssl.so/ext/sources/crypto/des/des_locl.h +432 -0
  328. data/lib/extensions/openssl.so/ext/sources/crypto/des/des_old.c +273 -0
  329. data/lib/extensions/openssl.so/ext/sources/crypto/des/des_old.h +446 -0
  330. data/lib/extensions/openssl.so/ext/sources/crypto/des/des_old2.c +82 -0
  331. data/lib/extensions/openssl.so/ext/sources/crypto/des/des_ver.h +71 -0
  332. data/lib/extensions/openssl.so/ext/sources/crypto/des/ecb3_enc.c +83 -0
  333. data/lib/extensions/openssl.so/ext/sources/crypto/des/ecb_enc.c +122 -0
  334. data/lib/extensions/openssl.so/ext/sources/crypto/des/ede_cbcm_enc.c +199 -0
  335. data/lib/extensions/openssl.so/ext/sources/crypto/des/enc_read.c +240 -0
  336. data/lib/extensions/openssl.so/ext/sources/crypto/des/enc_writ.c +179 -0
  337. data/lib/extensions/openssl.so/ext/sources/crypto/des/fcrypt.c +170 -0
  338. data/lib/extensions/openssl.so/ext/sources/crypto/des/fcrypt_b.c +143 -0
  339. data/lib/extensions/openssl.so/ext/sources/crypto/des/ncbc_enc.c +148 -0
  340. data/lib/extensions/openssl.so/ext/sources/crypto/des/ofb64ede.c +125 -0
  341. data/lib/extensions/openssl.so/ext/sources/crypto/des/ofb64enc.c +110 -0
  342. data/lib/extensions/openssl.so/ext/sources/crypto/des/ofb_enc.c +135 -0
  343. data/lib/extensions/openssl.so/ext/sources/crypto/des/pcbc_enc.c +123 -0
  344. data/lib/extensions/openssl.so/ext/sources/crypto/des/qud_cksm.c +139 -0
  345. data/lib/extensions/openssl.so/ext/sources/crypto/des/rand_key.c +68 -0
  346. data/lib/extensions/openssl.so/ext/sources/crypto/des/read2pwd.c +140 -0
  347. data/lib/extensions/openssl.so/ext/sources/crypto/des/rpc_des.h +131 -0
  348. data/lib/extensions/openssl.so/ext/sources/crypto/des/rpc_enc.c +98 -0
  349. data/lib/extensions/openssl.so/ext/sources/crypto/des/set_key.c +416 -0
  350. data/lib/extensions/openssl.so/ext/sources/crypto/des/spr.h +204 -0
  351. data/lib/extensions/openssl.so/ext/sources/crypto/des/str2key.c +174 -0
  352. data/lib/extensions/openssl.so/ext/sources/crypto/des/xcbc_enc.c +197 -0
  353. data/lib/extensions/openssl.so/ext/sources/crypto/dh/dh.h +280 -0
  354. data/lib/extensions/openssl.so/ext/sources/crypto/dh/dh_ameth.c +501 -0
  355. data/lib/extensions/openssl.so/ext/sources/crypto/dh/dh_asn1.c +93 -0
  356. data/lib/extensions/openssl.so/ext/sources/crypto/dh/dh_check.c +142 -0
  357. data/lib/extensions/openssl.so/ext/sources/crypto/dh/dh_depr.c +83 -0
  358. data/lib/extensions/openssl.so/ext/sources/crypto/dh/dh_err.c +122 -0
  359. data/lib/extensions/openssl.so/ext/sources/crypto/dh/dh_gen.c +192 -0
  360. data/lib/extensions/openssl.so/ext/sources/crypto/dh/dh_key.c +292 -0
  361. data/lib/extensions/openssl.so/ext/sources/crypto/dh/dh_lib.c +260 -0
  362. data/lib/extensions/openssl.so/ext/sources/crypto/dh/dh_pmeth.c +254 -0
  363. data/lib/extensions/openssl.so/ext/sources/crypto/dh/dh_prn.c +80 -0
  364. data/lib/extensions/openssl.so/ext/sources/crypto/dsa/dsa.h +327 -0
  365. data/lib/extensions/openssl.so/ext/sources/crypto/dsa/dsa_ameth.c +704 -0
  366. data/lib/extensions/openssl.so/ext/sources/crypto/dsa/dsa_asn1.c +188 -0
  367. data/lib/extensions/openssl.so/ext/sources/crypto/dsa/dsa_depr.c +106 -0
  368. data/lib/extensions/openssl.so/ext/sources/crypto/dsa/dsa_err.c +130 -0
  369. data/lib/extensions/openssl.so/ext/sources/crypto/dsa/dsa_gen.c +371 -0
  370. data/lib/extensions/openssl.so/ext/sources/crypto/dsa/dsa_key.c +144 -0
  371. data/lib/extensions/openssl.so/ext/sources/crypto/dsa/dsa_lib.c +329 -0
  372. data/lib/extensions/openssl.so/ext/sources/crypto/dsa/dsa_locl.h +60 -0
  373. data/lib/extensions/openssl.so/ext/sources/crypto/dsa/dsa_ossl.c +412 -0
  374. data/lib/extensions/openssl.so/ext/sources/crypto/dsa/dsa_pmeth.c +318 -0
  375. data/lib/extensions/openssl.so/ext/sources/crypto/dsa/dsa_prn.c +121 -0
  376. data/lib/extensions/openssl.so/ext/sources/crypto/dsa/dsa_sign.c +114 -0
  377. data/lib/extensions/openssl.so/ext/sources/crypto/dsa/dsa_vrf.c +76 -0
  378. data/lib/extensions/openssl.so/ext/sources/crypto/dso/dso.h +409 -0
  379. data/lib/extensions/openssl.so/ext/sources/crypto/dso/dso_beos.c +270 -0
  380. data/lib/extensions/openssl.so/ext/sources/crypto/dso/dso_dl.c +393 -0
  381. data/lib/extensions/openssl.so/ext/sources/crypto/dso/dso_dlfcn.c +484 -0
  382. data/lib/extensions/openssl.so/ext/sources/crypto/dso/dso_err.c +159 -0
  383. data/lib/extensions/openssl.so/ext/sources/crypto/dso/dso_lib.c +483 -0
  384. data/lib/extensions/openssl.so/ext/sources/crypto/dso/dso_null.c +90 -0
  385. data/lib/extensions/openssl.so/ext/sources/crypto/dso/dso_openssl.c +83 -0
  386. data/lib/extensions/openssl.so/ext/sources/crypto/dso/dso_vms.c +525 -0
  387. data/lib/extensions/openssl.so/ext/sources/crypto/dso/dso_win32.c +844 -0
  388. data/lib/extensions/openssl.so/ext/sources/crypto/ebcdic.c +221 -0
  389. data/lib/extensions/openssl.so/ext/sources/crypto/ebcdic.h +19 -0
  390. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ec.h +1159 -0
  391. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ec2_mult.c +390 -0
  392. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ec2_oct.c +407 -0
  393. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ec2_smpl.c +719 -0
  394. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ec_ameth.c +660 -0
  395. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ec_asn1.c +1447 -0
  396. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ec_check.c +123 -0
  397. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ec_curve.c +2100 -0
  398. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ec_cvt.c +170 -0
  399. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ec_err.c +276 -0
  400. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ec_key.c +563 -0
  401. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ec_lcl.h +446 -0
  402. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ec_lib.c +1096 -0
  403. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ec_mult.c +940 -0
  404. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ec_oct.c +199 -0
  405. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ec_pmeth.c +341 -0
  406. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ec_print.c +195 -0
  407. data/lib/extensions/openssl.so/ext/sources/crypto/ec/eck_prn.c +392 -0
  408. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ecp_mont.c +323 -0
  409. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ecp_nist.c +217 -0
  410. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ecp_nistp224.c +1658 -0
  411. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ecp_nistp256.c +2171 -0
  412. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ecp_nistp521.c +2025 -0
  413. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ecp_nistputil.c +197 -0
  414. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ecp_oct.c +433 -0
  415. data/lib/extensions/openssl.so/ext/sources/crypto/ec/ecp_smpl.c +1360 -0
  416. data/lib/extensions/openssl.so/ext/sources/crypto/ecdh/ecdh.h +125 -0
  417. data/lib/extensions/openssl.so/ext/sources/crypto/ecdh/ech_err.c +100 -0
  418. data/lib/extensions/openssl.so/ext/sources/crypto/ecdh/ech_key.c +83 -0
  419. data/lib/extensions/openssl.so/ext/sources/crypto/ecdh/ech_lib.c +266 -0
  420. data/lib/extensions/openssl.so/ext/sources/crypto/ecdh/ech_locl.h +102 -0
  421. data/lib/extensions/openssl.so/ext/sources/crypto/ecdh/ech_ossl.c +215 -0
  422. data/lib/extensions/openssl.so/ext/sources/crypto/ecdsa/ecdsa.h +260 -0
  423. data/lib/extensions/openssl.so/ext/sources/crypto/ecdsa/ecs_asn1.c +69 -0
  424. data/lib/extensions/openssl.so/ext/sources/crypto/ecdsa/ecs_err.c +106 -0
  425. data/lib/extensions/openssl.so/ext/sources/crypto/ecdsa/ecs_lib.c +278 -0
  426. data/lib/extensions/openssl.so/ext/sources/crypto/ecdsa/ecs_locl.h +115 -0
  427. data/lib/extensions/openssl.so/ext/sources/crypto/ecdsa/ecs_ossl.c +483 -0
  428. data/lib/extensions/openssl.so/ext/sources/crypto/ecdsa/ecs_sign.c +106 -0
  429. data/lib/extensions/openssl.so/ext/sources/crypto/ecdsa/ecs_vrf.c +96 -0
  430. data/lib/extensions/openssl.so/ext/sources/crypto/engine/eng_all.c +135 -0
  431. data/lib/extensions/openssl.so/ext/sources/crypto/engine/eng_cnf.c +259 -0
  432. data/lib/extensions/openssl.so/ext/sources/crypto/engine/eng_cryptodev.c +1450 -0
  433. data/lib/extensions/openssl.so/ext/sources/crypto/engine/eng_ctrl.c +389 -0
  434. data/lib/extensions/openssl.so/ext/sources/crypto/engine/eng_dyn.c +548 -0
  435. data/lib/extensions/openssl.so/ext/sources/crypto/engine/eng_err.c +173 -0
  436. data/lib/extensions/openssl.so/ext/sources/crypto/engine/eng_fat.c +182 -0
  437. data/lib/extensions/openssl.so/ext/sources/crypto/engine/eng_init.c +154 -0
  438. data/lib/extensions/openssl.so/ext/sources/crypto/engine/eng_int.h +206 -0
  439. data/lib/extensions/openssl.so/ext/sources/crypto/engine/eng_lib.c +332 -0
  440. data/lib/extensions/openssl.so/ext/sources/crypto/engine/eng_list.c +433 -0
  441. data/lib/extensions/openssl.so/ext/sources/crypto/engine/eng_openssl.c +384 -0
  442. data/lib/extensions/openssl.so/ext/sources/crypto/engine/eng_pkey.c +196 -0
  443. data/lib/extensions/openssl.so/ext/sources/crypto/engine/eng_rdrand.c +142 -0
  444. data/lib/extensions/openssl.so/ext/sources/crypto/engine/eng_rsax.c +668 -0
  445. data/lib/extensions/openssl.so/ext/sources/crypto/engine/eng_table.c +351 -0
  446. data/lib/extensions/openssl.so/ext/sources/crypto/engine/engine.h +842 -0
  447. data/lib/extensions/openssl.so/ext/sources/crypto/engine/tb_asnmth.c +246 -0
  448. data/lib/extensions/openssl.so/ext/sources/crypto/engine/tb_cipher.c +143 -0
  449. data/lib/extensions/openssl.so/ext/sources/crypto/engine/tb_dh.c +118 -0
  450. data/lib/extensions/openssl.so/ext/sources/crypto/engine/tb_digest.c +143 -0
  451. data/lib/extensions/openssl.so/ext/sources/crypto/engine/tb_dsa.c +118 -0
  452. data/lib/extensions/openssl.so/ext/sources/crypto/engine/tb_ecdh.c +133 -0
  453. data/lib/extensions/openssl.so/ext/sources/crypto/engine/tb_ecdsa.c +118 -0
  454. data/lib/extensions/openssl.so/ext/sources/crypto/engine/tb_pkmeth.c +167 -0
  455. data/lib/extensions/openssl.so/ext/sources/crypto/engine/tb_rand.c +118 -0
  456. data/lib/extensions/openssl.so/ext/sources/crypto/engine/tb_rsa.c +118 -0
  457. data/lib/extensions/openssl.so/ext/sources/crypto/engine/tb_store.c +123 -0
  458. data/lib/extensions/openssl.so/ext/sources/crypto/err/err.c +1138 -0
  459. data/lib/extensions/openssl.so/ext/sources/crypto/err/err.h +386 -0
  460. data/lib/extensions/openssl.so/ext/sources/crypto/err/err_all.c +167 -0
  461. data/lib/extensions/openssl.so/ext/sources/crypto/err/err_prn.c +114 -0
  462. data/lib/extensions/openssl.so/ext/sources/crypto/evp/bio_b64.c +598 -0
  463. data/lib/extensions/openssl.so/ext/sources/crypto/evp/bio_enc.c +428 -0
  464. data/lib/extensions/openssl.so/ext/sources/crypto/evp/bio_md.c +275 -0
  465. data/lib/extensions/openssl.so/ext/sources/crypto/evp/bio_ok.c +624 -0
  466. data/lib/extensions/openssl.so/ext/sources/crypto/evp/c_all.c +90 -0
  467. data/lib/extensions/openssl.so/ext/sources/crypto/evp/c_allc.c +230 -0
  468. data/lib/extensions/openssl.so/ext/sources/crypto/evp/c_alld.c +114 -0
  469. data/lib/extensions/openssl.so/ext/sources/crypto/evp/digest.c +403 -0
  470. data/lib/extensions/openssl.so/ext/sources/crypto/evp/e_aes.c +1313 -0
  471. data/lib/extensions/openssl.so/ext/sources/crypto/evp/e_aes_cbc_hmac_sha1.c +406 -0
  472. data/lib/extensions/openssl.so/ext/sources/crypto/evp/e_bf.c +88 -0
  473. data/lib/extensions/openssl.so/ext/sources/crypto/evp/e_camellia.c +131 -0
  474. data/lib/extensions/openssl.so/ext/sources/crypto/evp/e_cast.c +90 -0
  475. data/lib/extensions/openssl.so/ext/sources/crypto/evp/e_des.c +224 -0
  476. data/lib/extensions/openssl.so/ext/sources/crypto/evp/e_des3.c +316 -0
  477. data/lib/extensions/openssl.so/ext/sources/crypto/evp/e_idea.c +118 -0
  478. data/lib/extensions/openssl.so/ext/sources/crypto/evp/e_null.c +104 -0
  479. data/lib/extensions/openssl.so/ext/sources/crypto/evp/e_old.c +125 -0
  480. data/lib/extensions/openssl.so/ext/sources/crypto/evp/e_rc2.c +238 -0
  481. data/lib/extensions/openssl.so/ext/sources/crypto/evp/e_rc4.c +137 -0
  482. data/lib/extensions/openssl.so/ext/sources/crypto/evp/e_rc4_hmac_md5.c +298 -0
  483. data/lib/extensions/openssl.so/ext/sources/crypto/evp/e_rc5.c +126 -0
  484. data/lib/extensions/openssl.so/ext/sources/crypto/evp/e_seed.c +83 -0
  485. data/lib/extensions/openssl.so/ext/sources/crypto/evp/e_xcbc_d.c +138 -0
  486. data/lib/extensions/openssl.so/ext/sources/crypto/evp/encode.c +445 -0
  487. data/lib/extensions/openssl.so/ext/sources/crypto/evp/evp.h +1402 -0
  488. data/lib/extensions/openssl.so/ext/sources/crypto/evp/evp_acnf.c +73 -0
  489. data/lib/extensions/openssl.so/ext/sources/crypto/evp/evp_enc.c +681 -0
  490. data/lib/extensions/openssl.so/ext/sources/crypto/evp/evp_err.c +234 -0
  491. data/lib/extensions/openssl.so/ext/sources/crypto/evp/evp_fips.c +113 -0
  492. data/lib/extensions/openssl.so/ext/sources/crypto/evp/evp_key.c +189 -0
  493. data/lib/extensions/openssl.so/ext/sources/crypto/evp/evp_lib.c +316 -0
  494. data/lib/extensions/openssl.so/ext/sources/crypto/evp/evp_locl.h +385 -0
  495. data/lib/extensions/openssl.so/ext/sources/crypto/evp/evp_pbe.c +316 -0
  496. data/lib/extensions/openssl.so/ext/sources/crypto/evp/evp_pkey.c +242 -0
  497. data/lib/extensions/openssl.so/ext/sources/crypto/evp/m_dss.c +101 -0
  498. data/lib/extensions/openssl.so/ext/sources/crypto/evp/m_dss1.c +103 -0
  499. data/lib/extensions/openssl.so/ext/sources/crypto/evp/m_ecdsa.c +151 -0
  500. data/lib/extensions/openssl.so/ext/sources/crypto/evp/m_md4.c +103 -0
  501. data/lib/extensions/openssl.so/ext/sources/crypto/evp/m_md5.c +102 -0
  502. data/lib/extensions/openssl.so/ext/sources/crypto/evp/m_mdc2.c +103 -0
  503. data/lib/extensions/openssl.so/ext/sources/crypto/evp/m_null.c +95 -0
  504. data/lib/extensions/openssl.so/ext/sources/crypto/evp/m_ripemd.c +102 -0
  505. data/lib/extensions/openssl.so/ext/sources/crypto/evp/m_sha.c +101 -0
  506. data/lib/extensions/openssl.so/ext/sources/crypto/evp/m_sha1.c +209 -0
  507. data/lib/extensions/openssl.so/ext/sources/crypto/evp/m_sigver.c +200 -0
  508. data/lib/extensions/openssl.so/ext/sources/crypto/evp/m_wp.c +43 -0
  509. data/lib/extensions/openssl.so/ext/sources/crypto/evp/names.c +206 -0
  510. data/lib/extensions/openssl.so/ext/sources/crypto/evp/p5_crpt.c +143 -0
  511. data/lib/extensions/openssl.so/ext/sources/crypto/evp/p5_crpt2.c +322 -0
  512. data/lib/extensions/openssl.so/ext/sources/crypto/evp/p_dec.c +87 -0
  513. data/lib/extensions/openssl.so/ext/sources/crypto/evp/p_enc.c +86 -0
  514. data/lib/extensions/openssl.so/ext/sources/crypto/evp/p_lib.c +469 -0
  515. data/lib/extensions/openssl.so/ext/sources/crypto/evp/p_open.c +128 -0
  516. data/lib/extensions/openssl.so/ext/sources/crypto/evp/p_seal.c +116 -0
  517. data/lib/extensions/openssl.so/ext/sources/crypto/evp/p_sign.c +139 -0
  518. data/lib/extensions/openssl.so/ext/sources/crypto/evp/p_verify.c +121 -0
  519. data/lib/extensions/openssl.so/ext/sources/crypto/evp/pmeth_fn.c +368 -0
  520. data/lib/extensions/openssl.so/ext/sources/crypto/evp/pmeth_gn.c +221 -0
  521. data/lib/extensions/openssl.so/ext/sources/crypto/evp/pmeth_lib.c +593 -0
  522. data/lib/extensions/openssl.so/ext/sources/crypto/ex_data.c +636 -0
  523. data/lib/extensions/openssl.so/ext/sources/crypto/fips_err.h +209 -0
  524. data/lib/extensions/openssl.so/ext/sources/crypto/fips_ers.c +7 -0
  525. data/lib/extensions/openssl.so/ext/sources/crypto/hmac/hm_ameth.c +167 -0
  526. data/lib/extensions/openssl.so/ext/sources/crypto/hmac/hm_pmeth.c +271 -0
  527. data/lib/extensions/openssl.so/ext/sources/crypto/hmac/hmac.c +251 -0
  528. data/lib/extensions/openssl.so/ext/sources/crypto/hmac/hmac.h +110 -0
  529. data/lib/extensions/openssl.so/ext/sources/crypto/idea/i_cbc.c +168 -0
  530. data/lib/extensions/openssl.so/ext/sources/crypto/idea/i_cfb64.c +122 -0
  531. data/lib/extensions/openssl.so/ext/sources/crypto/idea/i_ecb.c +85 -0
  532. data/lib/extensions/openssl.so/ext/sources/crypto/idea/i_ofb64.c +111 -0
  533. data/lib/extensions/openssl.so/ext/sources/crypto/idea/i_skey.c +164 -0
  534. data/lib/extensions/openssl.so/ext/sources/crypto/idea/idea.h +103 -0
  535. data/lib/extensions/openssl.so/ext/sources/crypto/idea/idea_lcl.h +215 -0
  536. data/lib/extensions/openssl.so/ext/sources/crypto/krb5/krb5_asn.c +167 -0
  537. data/lib/extensions/openssl.so/ext/sources/crypto/krb5/krb5_asn.h +256 -0
  538. data/lib/extensions/openssl.so/ext/sources/crypto/lhash/lh_stats.c +248 -0
  539. data/lib/extensions/openssl.so/ext/sources/crypto/lhash/lhash.c +475 -0
  540. data/lib/extensions/openssl.so/ext/sources/crypto/lhash/lhash.h +241 -0
  541. data/lib/extensions/openssl.so/ext/sources/crypto/md32_common.h +415 -0
  542. data/lib/extensions/openssl.so/ext/sources/crypto/md4/md4.h +120 -0
  543. data/lib/extensions/openssl.so/ext/sources/crypto/md4/md4_dgst.c +168 -0
  544. data/lib/extensions/openssl.so/ext/sources/crypto/md4/md4_locl.h +112 -0
  545. data/lib/extensions/openssl.so/ext/sources/crypto/md4/md4_one.c +97 -0
  546. data/lib/extensions/openssl.so/ext/sources/crypto/md5/md5.h +120 -0
  547. data/lib/extensions/openssl.so/ext/sources/crypto/md5/md5_dgst.c +185 -0
  548. data/lib/extensions/openssl.so/ext/sources/crypto/md5/md5_locl.h +130 -0
  549. data/lib/extensions/openssl.so/ext/sources/crypto/md5/md5_one.c +97 -0
  550. data/lib/extensions/openssl.so/ext/sources/crypto/mdc2/mdc2.h +98 -0
  551. data/lib/extensions/openssl.so/ext/sources/crypto/mdc2/mdc2_one.c +76 -0
  552. data/lib/extensions/openssl.so/ext/sources/crypto/mdc2/mdc2dgst.c +200 -0
  553. data/lib/extensions/openssl.so/ext/sources/crypto/mem.c +420 -0
  554. data/lib/extensions/openssl.so/ext/sources/crypto/mem_clr.c +77 -0
  555. data/lib/extensions/openssl.so/ext/sources/crypto/mem_dbg.c +874 -0
  556. data/lib/extensions/openssl.so/ext/sources/crypto/modes/cbc128.c +202 -0
  557. data/lib/extensions/openssl.so/ext/sources/crypto/modes/ccm128.c +441 -0
  558. data/lib/extensions/openssl.so/ext/sources/crypto/modes/cfb128.c +242 -0
  559. data/lib/extensions/openssl.so/ext/sources/crypto/modes/ctr128.c +252 -0
  560. data/lib/extensions/openssl.so/ext/sources/crypto/modes/cts128.c +465 -0
  561. data/lib/extensions/openssl.so/ext/sources/crypto/modes/gcm128.c +1757 -0
  562. data/lib/extensions/openssl.so/ext/sources/crypto/modes/modes.h +135 -0
  563. data/lib/extensions/openssl.so/ext/sources/crypto/modes/modes_lcl.h +131 -0
  564. data/lib/extensions/openssl.so/ext/sources/crypto/modes/ofb128.c +121 -0
  565. data/lib/extensions/openssl.so/ext/sources/crypto/modes/xts128.c +187 -0
  566. data/lib/extensions/openssl.so/ext/sources/crypto/o_dir.c +83 -0
  567. data/lib/extensions/openssl.so/ext/sources/crypto/o_dir.h +53 -0
  568. data/lib/extensions/openssl.so/ext/sources/crypto/o_fips.c +96 -0
  569. data/lib/extensions/openssl.so/ext/sources/crypto/o_init.c +82 -0
  570. data/lib/extensions/openssl.so/ext/sources/crypto/o_str.c +111 -0
  571. data/lib/extensions/openssl.so/ext/sources/crypto/o_str.h +68 -0
  572. data/lib/extensions/openssl.so/ext/sources/crypto/o_time.c +372 -0
  573. data/lib/extensions/openssl.so/ext/sources/crypto/o_time.h +67 -0
  574. data/lib/extensions/openssl.so/ext/sources/crypto/objects/o_names.c +372 -0
  575. data/lib/extensions/openssl.so/ext/sources/crypto/objects/obj_dat.c +810 -0
  576. data/lib/extensions/openssl.so/ext/sources/crypto/objects/obj_dat.h +5102 -0
  577. data/lib/extensions/openssl.so/ext/sources/crypto/objects/obj_err.c +102 -0
  578. data/lib/extensions/openssl.so/ext/sources/crypto/objects/obj_lib.c +129 -0
  579. data/lib/extensions/openssl.so/ext/sources/crypto/objects/obj_mac.h +4032 -0
  580. data/lib/extensions/openssl.so/ext/sources/crypto/objects/obj_xref.c +234 -0
  581. data/lib/extensions/openssl.so/ext/sources/crypto/objects/obj_xref.h +77 -0
  582. data/lib/extensions/openssl.so/ext/sources/crypto/objects/objects.h +1138 -0
  583. data/lib/extensions/openssl.so/ext/sources/crypto/ocsp/ocsp.h +623 -0
  584. data/lib/extensions/openssl.so/ext/sources/crypto/ocsp/ocsp_asn.c +182 -0
  585. data/lib/extensions/openssl.so/ext/sources/crypto/ocsp/ocsp_cl.c +371 -0
  586. data/lib/extensions/openssl.so/ext/sources/crypto/ocsp/ocsp_err.c +142 -0
  587. data/lib/extensions/openssl.so/ext/sources/crypto/ocsp/ocsp_ext.c +518 -0
  588. data/lib/extensions/openssl.so/ext/sources/crypto/ocsp/ocsp_ht.c +504 -0
  589. data/lib/extensions/openssl.so/ext/sources/crypto/ocsp/ocsp_lib.c +266 -0
  590. data/lib/extensions/openssl.so/ext/sources/crypto/ocsp/ocsp_prn.c +290 -0
  591. data/lib/extensions/openssl.so/ext/sources/crypto/ocsp/ocsp_srv.c +264 -0
  592. data/lib/extensions/openssl.so/ext/sources/crypto/ocsp/ocsp_vfy.c +446 -0
  593. data/lib/extensions/openssl.so/ext/sources/crypto/opensslconf.h +230 -0
  594. data/lib/extensions/openssl.so/ext/sources/crypto/opensslconf.h.in +154 -0
  595. data/lib/extensions/openssl.so/ext/sources/crypto/opensslv.h +89 -0
  596. data/lib/extensions/openssl.so/ext/sources/crypto/ossl_typ.h +202 -0
  597. data/lib/extensions/openssl.so/ext/sources/crypto/pem/pem.h +641 -0
  598. data/lib/extensions/openssl.so/ext/sources/crypto/pem/pem2.h +70 -0
  599. data/lib/extensions/openssl.so/ext/sources/crypto/pem/pem_all.c +296 -0
  600. data/lib/extensions/openssl.so/ext/sources/crypto/pem/pem_err.c +161 -0
  601. data/lib/extensions/openssl.so/ext/sources/crypto/pem/pem_info.c +405 -0
  602. data/lib/extensions/openssl.so/ext/sources/crypto/pem/pem_lib.c +852 -0
  603. data/lib/extensions/openssl.so/ext/sources/crypto/pem/pem_oth.c +86 -0
  604. data/lib/extensions/openssl.so/ext/sources/crypto/pem/pem_pk8.c +242 -0
  605. data/lib/extensions/openssl.so/ext/sources/crypto/pem/pem_pkey.c +242 -0
  606. data/lib/extensions/openssl.so/ext/sources/crypto/pem/pem_seal.c +189 -0
  607. data/lib/extensions/openssl.so/ext/sources/crypto/pem/pem_sign.c +102 -0
  608. data/lib/extensions/openssl.so/ext/sources/crypto/pem/pem_x509.c +68 -0
  609. data/lib/extensions/openssl.so/ext/sources/crypto/pem/pem_xaux.c +68 -0
  610. data/lib/extensions/openssl.so/ext/sources/crypto/pem/pvkfmt.c +950 -0
  611. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs12/p12_add.c +240 -0
  612. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs12/p12_asn.c +125 -0
  613. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs12/p12_attr.c +145 -0
  614. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs12/p12_crpt.c +112 -0
  615. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs12/p12_crt.c +359 -0
  616. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs12/p12_decr.c +184 -0
  617. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs12/p12_init.c +92 -0
  618. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs12/p12_key.c +219 -0
  619. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs12/p12_kiss.c +302 -0
  620. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs12/p12_mutl.c +190 -0
  621. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs12/p12_npas.c +225 -0
  622. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs12/p12_p8d.c +68 -0
  623. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs12/p12_p8e.c +97 -0
  624. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs12/p12_utl.c +146 -0
  625. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs12/pk12err.c +144 -0
  626. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs12/pkcs12.h +331 -0
  627. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs7/bio_pk7.c +69 -0
  628. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs7/pk7_asn1.c +247 -0
  629. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs7/pk7_attr.c +165 -0
  630. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs7/pk7_doit.c +1299 -0
  631. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs7/pk7_lib.c +665 -0
  632. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs7/pk7_mime.c +97 -0
  633. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs7/pk7_smime.c +606 -0
  634. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs7/pkcs7.h +499 -0
  635. data/lib/extensions/openssl.so/ext/sources/crypto/pkcs7/pkcs7err.c +187 -0
  636. data/lib/extensions/openssl.so/ext/sources/crypto/pqueue/pqueue.c +252 -0
  637. data/lib/extensions/openssl.so/ext/sources/crypto/pqueue/pqueue.h +94 -0
  638. data/lib/extensions/openssl.so/ext/sources/crypto/rand/md_rand.c +592 -0
  639. data/lib/extensions/openssl.so/ext/sources/crypto/rand/rand.h +149 -0
  640. data/lib/extensions/openssl.so/ext/sources/crypto/rand/rand_egd.c +303 -0
  641. data/lib/extensions/openssl.so/ext/sources/crypto/rand/rand_err.c +100 -0
  642. data/lib/extensions/openssl.so/ext/sources/crypto/rand/rand_lcl.h +158 -0
  643. data/lib/extensions/openssl.so/ext/sources/crypto/rand/rand_lib.c +295 -0
  644. data/lib/extensions/openssl.so/ext/sources/crypto/rand/rand_nw.c +183 -0
  645. data/lib/extensions/openssl.so/ext/sources/crypto/rand/rand_os2.c +153 -0
  646. data/lib/extensions/openssl.so/ext/sources/crypto/rand/rand_unix.c +431 -0
  647. data/lib/extensions/openssl.so/ext/sources/crypto/rand/rand_win.c +807 -0
  648. data/lib/extensions/openssl.so/ext/sources/crypto/rand/randfile.c +326 -0
  649. data/lib/extensions/openssl.so/ext/sources/crypto/rc2/rc2.h +103 -0
  650. data/lib/extensions/openssl.so/ext/sources/crypto/rc2/rc2_cbc.c +226 -0
  651. data/lib/extensions/openssl.so/ext/sources/crypto/rc2/rc2_ecb.c +88 -0
  652. data/lib/extensions/openssl.so/ext/sources/crypto/rc2/rc2_locl.h +156 -0
  653. data/lib/extensions/openssl.so/ext/sources/crypto/rc2/rc2_skey.c +153 -0
  654. data/lib/extensions/openssl.so/ext/sources/crypto/rc2/rc2cfb64.c +122 -0
  655. data/lib/extensions/openssl.so/ext/sources/crypto/rc2/rc2ofb64.c +111 -0
  656. data/lib/extensions/openssl.so/ext/sources/crypto/rc4/rc4.h +90 -0
  657. data/lib/extensions/openssl.so/ext/sources/crypto/rc4/rc4_enc.c +315 -0
  658. data/lib/extensions/openssl.so/ext/sources/crypto/rc4/rc4_locl.h +5 -0
  659. data/lib/extensions/openssl.so/ext/sources/crypto/rc4/rc4_skey.c +116 -0
  660. data/lib/extensions/openssl.so/ext/sources/crypto/rc4/rc4_utl.c +62 -0
  661. data/lib/extensions/openssl.so/ext/sources/crypto/ripemd/ripemd.h +107 -0
  662. data/lib/extensions/openssl.so/ext/sources/crypto/ripemd/rmd_dgst.c +292 -0
  663. data/lib/extensions/openssl.so/ext/sources/crypto/ripemd/rmd_locl.h +150 -0
  664. data/lib/extensions/openssl.so/ext/sources/crypto/ripemd/rmd_one.c +78 -0
  665. data/lib/extensions/openssl.so/ext/sources/crypto/ripemd/rmdconst.h +399 -0
  666. data/lib/extensions/openssl.so/ext/sources/crypto/rsa/rsa.h +582 -0
  667. data/lib/extensions/openssl.so/ext/sources/crypto/rsa/rsa_ameth.c +698 -0
  668. data/lib/extensions/openssl.so/ext/sources/crypto/rsa/rsa_asn1.c +121 -0
  669. data/lib/extensions/openssl.so/ext/sources/crypto/rsa/rsa_chk.c +184 -0
  670. data/lib/extensions/openssl.so/ext/sources/crypto/rsa/rsa_crpt.c +257 -0
  671. data/lib/extensions/openssl.so/ext/sources/crypto/rsa/rsa_depr.c +101 -0
  672. data/lib/extensions/openssl.so/ext/sources/crypto/rsa/rsa_eay.c +915 -0
  673. data/lib/extensions/openssl.so/ext/sources/crypto/rsa/rsa_err.c +209 -0
  674. data/lib/extensions/openssl.so/ext/sources/crypto/rsa/rsa_gen.c +234 -0
  675. data/lib/extensions/openssl.so/ext/sources/crypto/rsa/rsa_lib.c +333 -0
  676. data/lib/extensions/openssl.so/ext/sources/crypto/rsa/rsa_locl.h +4 -0
  677. data/lib/extensions/openssl.so/ext/sources/crypto/rsa/rsa_none.c +98 -0
  678. data/lib/extensions/openssl.so/ext/sources/crypto/rsa/rsa_null.c +151 -0
  679. data/lib/extensions/openssl.so/ext/sources/crypto/rsa/rsa_oaep.c +235 -0
  680. data/lib/extensions/openssl.so/ext/sources/crypto/rsa/rsa_pk1.c +224 -0
  681. data/lib/extensions/openssl.so/ext/sources/crypto/rsa/rsa_pmeth.c +723 -0
  682. data/lib/extensions/openssl.so/ext/sources/crypto/rsa/rsa_prn.c +93 -0
  683. data/lib/extensions/openssl.so/ext/sources/crypto/rsa/rsa_pss.c +300 -0
  684. data/lib/extensions/openssl.so/ext/sources/crypto/rsa/rsa_saos.c +150 -0
  685. data/lib/extensions/openssl.so/ext/sources/crypto/rsa/rsa_sign.c +318 -0
  686. data/lib/extensions/openssl.so/ext/sources/crypto/rsa/rsa_ssl.c +154 -0
  687. data/lib/extensions/openssl.so/ext/sources/crypto/rsa/rsa_x931.c +177 -0
  688. data/lib/extensions/openssl.so/ext/sources/crypto/seed/seed.c +336 -0
  689. data/lib/extensions/openssl.so/ext/sources/crypto/seed/seed.h +139 -0
  690. data/lib/extensions/openssl.so/ext/sources/crypto/seed/seed_cbc.c +63 -0
  691. data/lib/extensions/openssl.so/ext/sources/crypto/seed/seed_cfb.c +116 -0
  692. data/lib/extensions/openssl.so/ext/sources/crypto/seed/seed_ecb.c +60 -0
  693. data/lib/extensions/openssl.so/ext/sources/crypto/seed/seed_locl.h +116 -0
  694. data/lib/extensions/openssl.so/ext/sources/crypto/seed/seed_ofb.c +116 -0
  695. data/lib/extensions/openssl.so/ext/sources/crypto/sha/sha.h +214 -0
  696. data/lib/extensions/openssl.so/ext/sources/crypto/sha/sha1_one.c +78 -0
  697. data/lib/extensions/openssl.so/ext/sources/crypto/sha/sha1dgst.c +75 -0
  698. data/lib/extensions/openssl.so/ext/sources/crypto/sha/sha256.c +282 -0
  699. data/lib/extensions/openssl.so/ext/sources/crypto/sha/sha512.c +597 -0
  700. data/lib/extensions/openssl.so/ext/sources/crypto/sha/sha_dgst.c +75 -0
  701. data/lib/extensions/openssl.so/ext/sources/crypto/sha/sha_locl.h +441 -0
  702. data/lib/extensions/openssl.so/ext/sources/crypto/sha/sha_one.c +78 -0
  703. data/lib/extensions/openssl.so/ext/sources/crypto/srp/srp.h +172 -0
  704. data/lib/extensions/openssl.so/ext/sources/crypto/srp/srp_grps.h +517 -0
  705. data/lib/extensions/openssl.so/ext/sources/crypto/srp/srp_lcl.h +83 -0
  706. data/lib/extensions/openssl.so/ext/sources/crypto/srp/srp_lib.c +357 -0
  707. data/lib/extensions/openssl.so/ext/sources/crypto/srp/srp_vfy.c +657 -0
  708. data/lib/extensions/openssl.so/ext/sources/crypto/stack/safestack.h +2663 -0
  709. data/lib/extensions/openssl.so/ext/sources/crypto/stack/stack.c +334 -0
  710. data/lib/extensions/openssl.so/ext/sources/crypto/stack/stack.h +108 -0
  711. data/lib/extensions/openssl.so/ext/sources/crypto/symhacks.h +477 -0
  712. data/lib/extensions/openssl.so/ext/sources/crypto/ts/ts.h +858 -0
  713. data/lib/extensions/openssl.so/ext/sources/crypto/ts/ts_asn1.c +322 -0
  714. data/lib/extensions/openssl.so/ext/sources/crypto/ts/ts_conf.c +507 -0
  715. data/lib/extensions/openssl.so/ext/sources/crypto/ts/ts_err.c +179 -0
  716. data/lib/extensions/openssl.so/ext/sources/crypto/ts/ts_lib.c +145 -0
  717. data/lib/extensions/openssl.so/ext/sources/crypto/ts/ts_req_print.c +102 -0
  718. data/lib/extensions/openssl.so/ext/sources/crypto/ts/ts_req_utils.c +234 -0
  719. data/lib/extensions/openssl.so/ext/sources/crypto/ts/ts_rsp_print.c +287 -0
  720. data/lib/extensions/openssl.so/ext/sources/crypto/ts/ts_rsp_sign.c +1020 -0
  721. data/lib/extensions/openssl.so/ext/sources/crypto/ts/ts_rsp_utils.c +409 -0
  722. data/lib/extensions/openssl.so/ext/sources/crypto/ts/ts_rsp_verify.c +728 -0
  723. data/lib/extensions/openssl.so/ext/sources/crypto/ts/ts_verify_ctx.c +159 -0
  724. data/lib/extensions/openssl.so/ext/sources/crypto/txt_db/txt_db.c +388 -0
  725. data/lib/extensions/openssl.so/ext/sources/crypto/txt_db/txt_db.h +112 -0
  726. data/lib/extensions/openssl.so/ext/sources/crypto/ui/ui.h +383 -0
  727. data/lib/extensions/openssl.so/ext/sources/crypto/ui/ui_compat.c +67 -0
  728. data/lib/extensions/openssl.so/ext/sources/crypto/ui/ui_compat.h +83 -0
  729. data/lib/extensions/openssl.so/ext/sources/crypto/ui/ui_err.c +112 -0
  730. data/lib/extensions/openssl.so/ext/sources/crypto/ui/ui_lib.c +924 -0
  731. data/lib/extensions/openssl.so/ext/sources/crypto/ui/ui_locl.h +153 -0
  732. data/lib/extensions/openssl.so/ext/sources/crypto/ui/ui_openssl.c +712 -0
  733. data/lib/extensions/openssl.so/ext/sources/crypto/ui/ui_util.c +91 -0
  734. data/lib/extensions/openssl.so/ext/sources/crypto/uid.c +89 -0
  735. data/lib/extensions/openssl.so/ext/sources/crypto/vms_rms.h +51 -0
  736. data/lib/extensions/openssl.so/ext/sources/crypto/whrlpool/whrlpool.h +41 -0
  737. data/lib/extensions/openssl.so/ext/sources/crypto/whrlpool/wp_block.c +655 -0
  738. data/lib/extensions/openssl.so/ext/sources/crypto/whrlpool/wp_dgst.c +265 -0
  739. data/lib/extensions/openssl.so/ext/sources/crypto/whrlpool/wp_locl.h +3 -0
  740. data/lib/extensions/openssl.so/ext/sources/crypto/x509/by_dir.c +482 -0
  741. data/lib/extensions/openssl.so/ext/sources/crypto/x509/by_file.c +300 -0
  742. data/lib/extensions/openssl.so/ext/sources/crypto/x509/x509.h +1297 -0
  743. data/lib/extensions/openssl.so/ext/sources/crypto/x509/x509_att.c +359 -0
  744. data/lib/extensions/openssl.so/ext/sources/crypto/x509/x509_cmp.c +344 -0
  745. data/lib/extensions/openssl.so/ext/sources/crypto/x509/x509_d2.c +107 -0
  746. data/lib/extensions/openssl.so/ext/sources/crypto/x509/x509_def.c +81 -0
  747. data/lib/extensions/openssl.so/ext/sources/crypto/x509/x509_err.c +164 -0
  748. data/lib/extensions/openssl.so/ext/sources/crypto/x509/x509_ext.c +210 -0
  749. data/lib/extensions/openssl.so/ext/sources/crypto/x509/x509_lu.c +716 -0
  750. data/lib/extensions/openssl.so/ext/sources/crypto/x509/x509_obj.c +226 -0
  751. data/lib/extensions/openssl.so/ext/sources/crypto/x509/x509_r2x.c +114 -0
  752. data/lib/extensions/openssl.so/ext/sources/crypto/x509/x509_req.c +316 -0
  753. data/lib/extensions/openssl.so/ext/sources/crypto/x509/x509_set.c +150 -0
  754. data/lib/extensions/openssl.so/ext/sources/crypto/x509/x509_trs.c +288 -0
  755. data/lib/extensions/openssl.so/ext/sources/crypto/x509/x509_txt.c +193 -0
  756. data/lib/extensions/openssl.so/ext/sources/crypto/x509/x509_v3.c +274 -0
  757. data/lib/extensions/openssl.so/ext/sources/crypto/x509/x509_vfy.c +2214 -0
  758. data/lib/extensions/openssl.so/ext/sources/crypto/x509/x509_vfy.h +567 -0
  759. data/lib/extensions/openssl.so/ext/sources/crypto/x509/x509_vpm.c +438 -0
  760. data/lib/extensions/openssl.so/ext/sources/crypto/x509/x509cset.c +170 -0
  761. data/lib/extensions/openssl.so/ext/sources/crypto/x509/x509name.c +383 -0
  762. data/lib/extensions/openssl.so/ext/sources/crypto/x509/x509rset.c +83 -0
  763. data/lib/extensions/openssl.so/ext/sources/crypto/x509/x509spki.c +121 -0
  764. data/lib/extensions/openssl.so/ext/sources/crypto/x509/x509type.c +131 -0
  765. data/lib/extensions/openssl.so/ext/sources/crypto/x509/x_all.c +535 -0
  766. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/ext_dat.h +132 -0
  767. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/pcy_cache.c +286 -0
  768. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/pcy_data.c +135 -0
  769. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/pcy_int.h +212 -0
  770. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/pcy_lib.c +167 -0
  771. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/pcy_map.c +132 -0
  772. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/pcy_node.c +197 -0
  773. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/pcy_tree.c +872 -0
  774. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_addr.c +1338 -0
  775. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_akey.c +208 -0
  776. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_akeya.c +72 -0
  777. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_alt.c +614 -0
  778. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_asid.c +890 -0
  779. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_bcons.c +124 -0
  780. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_bitst.c +141 -0
  781. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_conf.c +525 -0
  782. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_cpols.c +457 -0
  783. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_crld.c +616 -0
  784. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_enum.c +97 -0
  785. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_extku.c +144 -0
  786. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_genn.c +252 -0
  787. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_ia5.c +116 -0
  788. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_info.c +193 -0
  789. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_int.c +89 -0
  790. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_lib.c +309 -0
  791. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_ncons.c +505 -0
  792. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_ocsp.c +289 -0
  793. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_pci.c +328 -0
  794. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_pcia.c +55 -0
  795. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_pcons.c +140 -0
  796. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_pku.c +108 -0
  797. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_pmaps.c +155 -0
  798. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_prn.c +234 -0
  799. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_purp.c +767 -0
  800. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_skey.c +145 -0
  801. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_sxnet.c +262 -0
  802. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3_utl.c +874 -0
  803. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/v3err.c +226 -0
  804. data/lib/extensions/openssl.so/ext/sources/crypto/x509v3/x509v3.h +1007 -0
  805. data/lib/extensions/openssl.so/ext/sources/e_os.h +735 -0
  806. data/lib/extensions/openssl.so/ext/sources/e_os2.h +315 -0
  807. data/lib/extensions/openssl.so/ext/sources/engines/ccgost/e_gost_err.c +212 -0
  808. data/lib/extensions/openssl.so/ext/sources/engines/ccgost/e_gost_err.h +156 -0
  809. data/lib/extensions/openssl.so/ext/sources/engines/ccgost/gost2001.c +343 -0
  810. data/lib/extensions/openssl.so/ext/sources/engines/ccgost/gost2001_keyx.c +308 -0
  811. data/lib/extensions/openssl.so/ext/sources/engines/ccgost/gost2001_keyx.h +10 -0
  812. data/lib/extensions/openssl.so/ext/sources/engines/ccgost/gost89.c +409 -0
  813. data/lib/extensions/openssl.so/ext/sources/engines/ccgost/gost89.h +96 -0
  814. data/lib/extensions/openssl.so/ext/sources/engines/ccgost/gost94_keyx.c +291 -0
  815. data/lib/extensions/openssl.so/ext/sources/engines/ccgost/gost_ameth.c +945 -0
  816. data/lib/extensions/openssl.so/ext/sources/engines/ccgost/gost_asn1.c +55 -0
  817. data/lib/extensions/openssl.so/ext/sources/engines/ccgost/gost_crypt.c +617 -0
  818. data/lib/extensions/openssl.so/ext/sources/engines/ccgost/gost_ctl.c +89 -0
  819. data/lib/extensions/openssl.so/ext/sources/engines/ccgost/gost_eng.c +273 -0
  820. data/lib/extensions/openssl.so/ext/sources/engines/ccgost/gost_keywrap.c +109 -0
  821. data/lib/extensions/openssl.so/ext/sources/engines/ccgost/gost_keywrap.h +56 -0
  822. data/lib/extensions/openssl.so/ext/sources/engines/ccgost/gost_lcl.h +221 -0
  823. data/lib/extensions/openssl.so/ext/sources/engines/ccgost/gost_md.c +75 -0
  824. data/lib/extensions/openssl.so/ext/sources/engines/ccgost/gost_params.c +198 -0
  825. data/lib/extensions/openssl.so/ext/sources/engines/ccgost/gost_params.h +34 -0
  826. data/lib/extensions/openssl.so/ext/sources/engines/ccgost/gost_pmeth.c +628 -0
  827. data/lib/extensions/openssl.so/ext/sources/engines/ccgost/gost_sign.c +321 -0
  828. data/lib/extensions/openssl.so/ext/sources/engines/ccgost/gosthash.c +255 -0
  829. data/lib/extensions/openssl.so/ext/sources/engines/ccgost/gosthash.h +48 -0
  830. data/lib/extensions/openssl.so/ext/sources/engines/e_4758cca.c +987 -0
  831. data/lib/extensions/openssl.so/ext/sources/engines/e_4758cca_err.c +153 -0
  832. data/lib/extensions/openssl.so/ext/sources/engines/e_4758cca_err.h +97 -0
  833. data/lib/extensions/openssl.so/ext/sources/engines/e_aep.c +1139 -0
  834. data/lib/extensions/openssl.so/ext/sources/engines/e_aep_err.c +161 -0
  835. data/lib/extensions/openssl.so/ext/sources/engines/e_aep_err.h +105 -0
  836. data/lib/extensions/openssl.so/ext/sources/engines/e_atalla.c +607 -0
  837. data/lib/extensions/openssl.so/ext/sources/engines/e_atalla_err.c +149 -0
  838. data/lib/extensions/openssl.so/ext/sources/engines/e_atalla_err.h +93 -0
  839. data/lib/extensions/openssl.so/ext/sources/engines/e_capi.c +1913 -0
  840. data/lib/extensions/openssl.so/ext/sources/engines/e_capi_err.c +184 -0
  841. data/lib/extensions/openssl.so/ext/sources/engines/e_capi_err.h +128 -0
  842. data/lib/extensions/openssl.so/ext/sources/engines/e_chil.c +1356 -0
  843. data/lib/extensions/openssl.so/ext/sources/engines/e_chil_err.c +160 -0
  844. data/lib/extensions/openssl.so/ext/sources/engines/e_chil_err.h +104 -0
  845. data/lib/extensions/openssl.so/ext/sources/engines/e_cswift.c +1129 -0
  846. data/lib/extensions/openssl.so/ext/sources/engines/e_cswift_err.c +154 -0
  847. data/lib/extensions/openssl.so/ext/sources/engines/e_cswift_err.h +98 -0
  848. data/lib/extensions/openssl.so/ext/sources/engines/e_gmp.c +480 -0
  849. data/lib/extensions/openssl.so/ext/sources/engines/e_gmp_err.c +141 -0
  850. data/lib/extensions/openssl.so/ext/sources/engines/e_gmp_err.h +85 -0
  851. data/lib/extensions/openssl.so/ext/sources/engines/e_nuron.c +434 -0
  852. data/lib/extensions/openssl.so/ext/sources/engines/e_nuron_err.c +146 -0
  853. data/lib/extensions/openssl.so/ext/sources/engines/e_nuron_err.h +90 -0
  854. data/lib/extensions/openssl.so/ext/sources/engines/e_padlock.c +1239 -0
  855. data/lib/extensions/openssl.so/ext/sources/engines/e_sureware.c +1055 -0
  856. data/lib/extensions/openssl.so/ext/sources/engines/e_sureware_err.c +158 -0
  857. data/lib/extensions/openssl.so/ext/sources/engines/e_sureware_err.h +102 -0
  858. data/lib/extensions/openssl.so/ext/sources/engines/e_ubsec.c +1069 -0
  859. data/lib/extensions/openssl.so/ext/sources/engines/e_ubsec_err.c +157 -0
  860. data/lib/extensions/openssl.so/ext/sources/engines/e_ubsec_err.h +101 -0
  861. data/lib/extensions/openssl.so/ext/sources/engines/vendor_defns/aep.h +178 -0
  862. data/lib/extensions/openssl.so/ext/sources/engines/vendor_defns/atalla.h +48 -0
  863. data/lib/extensions/openssl.so/ext/sources/engines/vendor_defns/cswift.h +234 -0
  864. data/lib/extensions/openssl.so/ext/sources/engines/vendor_defns/hw_4758_cca.h +149 -0
  865. data/lib/extensions/openssl.so/ext/sources/engines/vendor_defns/hw_ubsec.h +100 -0
  866. data/lib/extensions/openssl.so/ext/sources/engines/vendor_defns/hwcryptohook.h +486 -0
  867. data/lib/extensions/openssl.so/ext/sources/engines/vendor_defns/sureware.h +239 -0
  868. data/lib/extensions/openssl.so/ext/sources/include/openssl/aes.h +1 -0
  869. data/lib/extensions/openssl.so/ext/sources/include/openssl/asn1.h +1 -0
  870. data/lib/extensions/openssl.so/ext/sources/include/openssl/asn1_mac.h +1 -0
  871. data/lib/extensions/openssl.so/ext/sources/include/openssl/asn1t.h +1 -0
  872. data/lib/extensions/openssl.so/ext/sources/include/openssl/bio.h +1 -0
  873. data/lib/extensions/openssl.so/ext/sources/include/openssl/blowfish.h +1 -0
  874. data/lib/extensions/openssl.so/ext/sources/include/openssl/bn.h +1 -0
  875. data/lib/extensions/openssl.so/ext/sources/include/openssl/buffer.h +1 -0
  876. data/lib/extensions/openssl.so/ext/sources/include/openssl/camellia.h +1 -0
  877. data/lib/extensions/openssl.so/ext/sources/include/openssl/cast.h +1 -0
  878. data/lib/extensions/openssl.so/ext/sources/include/openssl/cmac.h +1 -0
  879. data/lib/extensions/openssl.so/ext/sources/include/openssl/cms.h +1 -0
  880. data/lib/extensions/openssl.so/ext/sources/include/openssl/comp.h +1 -0
  881. data/lib/extensions/openssl.so/ext/sources/include/openssl/conf.h +1 -0
  882. data/lib/extensions/openssl.so/ext/sources/include/openssl/conf_api.h +1 -0
  883. data/lib/extensions/openssl.so/ext/sources/include/openssl/crypto.h +1 -0
  884. data/lib/extensions/openssl.so/ext/sources/include/openssl/des.h +1 -0
  885. data/lib/extensions/openssl.so/ext/sources/include/openssl/des_old.h +1 -0
  886. data/lib/extensions/openssl.so/ext/sources/include/openssl/dh.h +1 -0
  887. data/lib/extensions/openssl.so/ext/sources/include/openssl/dsa.h +1 -0
  888. data/lib/extensions/openssl.so/ext/sources/include/openssl/dso.h +1 -0
  889. data/lib/extensions/openssl.so/ext/sources/include/openssl/dtls1.h +1 -0
  890. data/lib/extensions/openssl.so/ext/sources/include/openssl/e_os2.h +1 -0
  891. data/lib/extensions/openssl.so/ext/sources/include/openssl/ebcdic.h +1 -0
  892. data/lib/extensions/openssl.so/ext/sources/include/openssl/ec.h +1 -0
  893. data/lib/extensions/openssl.so/ext/sources/include/openssl/ecdh.h +1 -0
  894. data/lib/extensions/openssl.so/ext/sources/include/openssl/ecdsa.h +1 -0
  895. data/lib/extensions/openssl.so/ext/sources/include/openssl/engine.h +1 -0
  896. data/lib/extensions/openssl.so/ext/sources/include/openssl/err.h +1 -0
  897. data/lib/extensions/openssl.so/ext/sources/include/openssl/evp.h +1 -0
  898. data/lib/extensions/openssl.so/ext/sources/include/openssl/hmac.h +1 -0
  899. data/lib/extensions/openssl.so/ext/sources/include/openssl/idea.h +1 -0
  900. data/lib/extensions/openssl.so/ext/sources/include/openssl/krb5_asn.h +1 -0
  901. data/lib/extensions/openssl.so/ext/sources/include/openssl/kssl.h +1 -0
  902. data/lib/extensions/openssl.so/ext/sources/include/openssl/lhash.h +1 -0
  903. data/lib/extensions/openssl.so/ext/sources/include/openssl/md4.h +1 -0
  904. data/lib/extensions/openssl.so/ext/sources/include/openssl/md5.h +1 -0
  905. data/lib/extensions/openssl.so/ext/sources/include/openssl/mdc2.h +1 -0
  906. data/lib/extensions/openssl.so/ext/sources/include/openssl/modes.h +1 -0
  907. data/lib/extensions/openssl.so/ext/sources/include/openssl/obj_mac.h +1 -0
  908. data/lib/extensions/openssl.so/ext/sources/include/openssl/objects.h +1 -0
  909. data/lib/extensions/openssl.so/ext/sources/include/openssl/ocsp.h +1 -0
  910. data/lib/extensions/openssl.so/ext/sources/include/openssl/opensslconf.h +1 -0
  911. data/lib/extensions/openssl.so/ext/sources/include/openssl/opensslv.h +1 -0
  912. data/lib/extensions/openssl.so/ext/sources/include/openssl/ossl_typ.h +1 -0
  913. data/lib/extensions/openssl.so/ext/sources/include/openssl/pem.h +1 -0
  914. data/lib/extensions/openssl.so/ext/sources/include/openssl/pem2.h +1 -0
  915. data/lib/extensions/openssl.so/ext/sources/include/openssl/pkcs12.h +1 -0
  916. data/lib/extensions/openssl.so/ext/sources/include/openssl/pkcs7.h +1 -0
  917. data/lib/extensions/openssl.so/ext/sources/include/openssl/pqueue.h +1 -0
  918. data/lib/extensions/openssl.so/ext/sources/include/openssl/rand.h +1 -0
  919. data/lib/extensions/openssl.so/ext/sources/include/openssl/rc2.h +1 -0
  920. data/lib/extensions/openssl.so/ext/sources/include/openssl/rc4.h +1 -0
  921. data/lib/extensions/openssl.so/ext/sources/include/openssl/ripemd.h +1 -0
  922. data/lib/extensions/openssl.so/ext/sources/include/openssl/rsa.h +1 -0
  923. data/lib/extensions/openssl.so/ext/sources/include/openssl/safestack.h +1 -0
  924. data/lib/extensions/openssl.so/ext/sources/include/openssl/seed.h +1 -0
  925. data/lib/extensions/openssl.so/ext/sources/include/openssl/sha.h +1 -0
  926. data/lib/extensions/openssl.so/ext/sources/include/openssl/srp.h +1 -0
  927. data/lib/extensions/openssl.so/ext/sources/include/openssl/srtp.h +1 -0
  928. data/lib/extensions/openssl.so/ext/sources/include/openssl/ssl.h +1 -0
  929. data/lib/extensions/openssl.so/ext/sources/include/openssl/ssl2.h +1 -0
  930. data/lib/extensions/openssl.so/ext/sources/include/openssl/ssl23.h +1 -0
  931. data/lib/extensions/openssl.so/ext/sources/include/openssl/ssl3.h +1 -0
  932. data/lib/extensions/openssl.so/ext/sources/include/openssl/stack.h +1 -0
  933. data/lib/extensions/openssl.so/ext/sources/include/openssl/store.h +1 -0
  934. data/lib/extensions/openssl.so/ext/sources/include/openssl/symhacks.h +1 -0
  935. data/lib/extensions/openssl.so/ext/sources/include/openssl/tls1.h +1 -0
  936. data/lib/extensions/openssl.so/ext/sources/include/openssl/ts.h +1 -0
  937. data/lib/extensions/openssl.so/ext/sources/include/openssl/txt_db.h +1 -0
  938. data/lib/extensions/openssl.so/ext/sources/include/openssl/ui.h +1 -0
  939. data/lib/extensions/openssl.so/ext/sources/include/openssl/ui_compat.h +1 -0
  940. data/lib/extensions/openssl.so/ext/sources/include/openssl/whrlpool.h +1 -0
  941. data/lib/extensions/openssl.so/ext/sources/include/openssl/x509.h +1 -0
  942. data/lib/extensions/openssl.so/ext/sources/include/openssl/x509_vfy.h +1 -0
  943. data/lib/extensions/openssl.so/ext/sources/include/openssl/x509v3.h +1 -0
  944. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/assert.h +50 -0
  945. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/conio.h +40 -0
  946. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/ctype.h +90 -0
  947. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/direct.h +22 -0
  948. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/errno.h +158 -0
  949. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/fcntl.h +56 -0
  950. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/float.h +330 -0
  951. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/io.h +63 -0
  952. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/limits.h +95 -0
  953. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/malloc.h +59 -0
  954. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/math.h +95 -0
  955. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/memory.h +44 -0
  956. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/process.h +59 -0
  957. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/setjmp.h +69 -0
  958. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/signal.h +53 -0
  959. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/stdarg.h +78 -0
  960. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/stddef.h +88 -0
  961. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/stdio.h +182 -0
  962. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/stdlib.h +142 -0
  963. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/string.h +109 -0
  964. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/strings.h +3 -0
  965. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/sys/locking.h +31 -0
  966. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/sys/stat.h +92 -0
  967. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/sys/time.h +20 -0
  968. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/sys/timeb.h +58 -0
  969. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/sys/types.h +35 -0
  970. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/sys/utime.h +21 -0
  971. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/time.h +81 -0
  972. data/lib/extensions/openssl.so/ext/sources/include/wcecompat/winsock_extras.h +46 -0
  973. data/lib/extensions/openssl.so/ext/sources/ssl/bio_ssl.c +605 -0
  974. data/lib/extensions/openssl.so/ext/sources/ssl/d1_both.c +1591 -0
  975. data/lib/extensions/openssl.so/ext/sources/ssl/d1_clnt.c +1710 -0
  976. data/lib/extensions/openssl.so/ext/sources/ssl/d1_enc.c +289 -0
  977. data/lib/extensions/openssl.so/ext/sources/ssl/d1_lib.c +482 -0
  978. data/lib/extensions/openssl.so/ext/sources/ssl/d1_meth.c +77 -0
  979. data/lib/extensions/openssl.so/ext/sources/ssl/d1_pkt.c +1876 -0
  980. data/lib/extensions/openssl.so/ext/sources/ssl/d1_srtp.c +493 -0
  981. data/lib/extensions/openssl.so/ext/sources/ssl/d1_srvr.c +1711 -0
  982. data/lib/extensions/openssl.so/ext/sources/ssl/dtls1.h +283 -0
  983. data/lib/extensions/openssl.so/ext/sources/ssl/kssl.c +2221 -0
  984. data/lib/extensions/openssl.so/ext/sources/ssl/kssl.h +183 -0
  985. data/lib/extensions/openssl.so/ext/sources/ssl/kssl_lcl.h +87 -0
  986. data/lib/extensions/openssl.so/ext/sources/ssl/s23_clnt.c +779 -0
  987. data/lib/extensions/openssl.so/ext/sources/ssl/s23_lib.c +187 -0
  988. data/lib/extensions/openssl.so/ext/sources/ssl/s23_meth.c +92 -0
  989. data/lib/extensions/openssl.so/ext/sources/ssl/s23_pkt.c +117 -0
  990. data/lib/extensions/openssl.so/ext/sources/ssl/s23_srvr.c +638 -0
  991. data/lib/extensions/openssl.so/ext/sources/ssl/s2_clnt.c +1125 -0
  992. data/lib/extensions/openssl.so/ext/sources/ssl/s2_enc.c +193 -0
  993. data/lib/extensions/openssl.so/ext/sources/ssl/s2_lib.c +556 -0
  994. data/lib/extensions/openssl.so/ext/sources/ssl/s2_meth.c +84 -0
  995. data/lib/extensions/openssl.so/ext/sources/ssl/s2_pkt.c +744 -0
  996. data/lib/extensions/openssl.so/ext/sources/ssl/s2_srvr.c +1142 -0
  997. data/lib/extensions/openssl.so/ext/sources/ssl/s3_both.c +843 -0
  998. data/lib/extensions/openssl.so/ext/sources/ssl/s3_clnt.c +3371 -0
  999. data/lib/extensions/openssl.so/ext/sources/ssl/s3_enc.c +861 -0
  1000. data/lib/extensions/openssl.so/ext/sources/ssl/s3_lib.c +4282 -0
  1001. data/lib/extensions/openssl.so/ext/sources/ssl/s3_meth.c +77 -0
  1002. data/lib/extensions/openssl.so/ext/sources/ssl/s3_pkt.c +1518 -0
  1003. data/lib/extensions/openssl.so/ext/sources/ssl/s3_srvr.c +3586 -0
  1004. data/lib/extensions/openssl.so/ext/sources/ssl/srtp.h +145 -0
  1005. data/lib/extensions/openssl.so/ext/sources/ssl/ssl.h +2573 -0
  1006. data/lib/extensions/openssl.so/ext/sources/ssl/ssl2.h +272 -0
  1007. data/lib/extensions/openssl.so/ext/sources/ssl/ssl23.h +83 -0
  1008. data/lib/extensions/openssl.so/ext/sources/ssl/ssl3.h +678 -0
  1009. data/lib/extensions/openssl.so/ext/sources/ssl/ssl_algs.c +149 -0
  1010. data/lib/extensions/openssl.so/ext/sources/ssl/ssl_asn1.c +642 -0
  1011. data/lib/extensions/openssl.so/ext/sources/ssl/ssl_cert.c +853 -0
  1012. data/lib/extensions/openssl.so/ext/sources/ssl/ssl_ciph.c +1852 -0
  1013. data/lib/extensions/openssl.so/ext/sources/ssl/ssl_err.c +609 -0
  1014. data/lib/extensions/openssl.so/ext/sources/ssl/ssl_err2.c +70 -0
  1015. data/lib/extensions/openssl.so/ext/sources/ssl/ssl_lib.c +3251 -0
  1016. data/lib/extensions/openssl.so/ext/sources/ssl/ssl_locl.h +1134 -0
  1017. data/lib/extensions/openssl.so/ext/sources/ssl/ssl_rsa.c +779 -0
  1018. data/lib/extensions/openssl.so/ext/sources/ssl/ssl_sess.c +1159 -0
  1019. data/lib/extensions/openssl.so/ext/sources/ssl/ssl_stat.c +567 -0
  1020. data/lib/extensions/openssl.so/ext/sources/ssl/ssl_txt.c +248 -0
  1021. data/lib/extensions/openssl.so/ext/sources/ssl/t1_clnt.c +92 -0
  1022. data/lib/extensions/openssl.so/ext/sources/ssl/t1_enc.c +1256 -0
  1023. data/lib/extensions/openssl.so/ext/sources/ssl/t1_lib.c +2578 -0
  1024. data/lib/extensions/openssl.so/ext/sources/ssl/t1_meth.c +88 -0
  1025. data/lib/extensions/openssl.so/ext/sources/ssl/t1_reneg.c +292 -0
  1026. data/lib/extensions/openssl.so/ext/sources/ssl/t1_srvr.c +93 -0
  1027. data/lib/extensions/openssl.so/ext/sources/ssl/tls1.h +735 -0
  1028. data/lib/extensions/openssl.so/ext/sources/ssl/tls_srp.c +506 -0
  1029. data/lib/extensions/openssl.so/ext/win32/UPDATE +15 -0
  1030. data/lib/extensions/openssl.so/ext/win32/bin/libeay32.dll +0 -0
  1031. data/lib/extensions/openssl.so/ext/win32/bin/ssleay32.dll +0 -0
  1032. data/lib/extensions/openssl.so/ext/win32/include/openssl/aes.h +147 -0
  1033. data/lib/extensions/openssl.so/ext/win32/include/openssl/applink.c +94 -0
  1034. data/lib/extensions/openssl.so/ext/win32/include/openssl/asn1.h +1404 -0
  1035. data/lib/extensions/openssl.so/ext/win32/include/openssl/asn1_mac.h +578 -0
  1036. data/lib/extensions/openssl.so/ext/win32/include/openssl/asn1t.h +960 -0
  1037. data/lib/extensions/openssl.so/ext/win32/include/openssl/bio.h +847 -0
  1038. data/lib/extensions/openssl.so/ext/win32/include/openssl/blowfish.h +129 -0
  1039. data/lib/extensions/openssl.so/ext/win32/include/openssl/bn.h +891 -0
  1040. data/lib/extensions/openssl.so/ext/win32/include/openssl/buffer.h +119 -0
  1041. data/lib/extensions/openssl.so/ext/win32/include/openssl/camellia.h +130 -0
  1042. data/lib/extensions/openssl.so/ext/win32/include/openssl/cast.h +107 -0
  1043. data/lib/extensions/openssl.so/ext/win32/include/openssl/cmac.h +82 -0
  1044. data/lib/extensions/openssl.so/ext/win32/include/openssl/cms.h +501 -0
  1045. data/lib/extensions/openssl.so/ext/win32/include/openssl/comp.h +80 -0
  1046. data/lib/extensions/openssl.so/ext/win32/include/openssl/conf.h +263 -0
  1047. data/lib/extensions/openssl.so/ext/win32/include/openssl/conf_api.h +89 -0
  1048. data/lib/extensions/openssl.so/ext/win32/include/openssl/crypto.h +604 -0
  1049. data/lib/extensions/openssl.so/ext/win32/include/openssl/des.h +248 -0
  1050. data/lib/extensions/openssl.so/ext/win32/include/openssl/des_old.h +446 -0
  1051. data/lib/extensions/openssl.so/ext/win32/include/openssl/dh.h +280 -0
  1052. data/lib/extensions/openssl.so/ext/win32/include/openssl/dsa.h +327 -0
  1053. data/lib/extensions/openssl.so/ext/win32/include/openssl/dso.h +409 -0
  1054. data/lib/extensions/openssl.so/ext/win32/include/openssl/dtls1.h +283 -0
  1055. data/lib/extensions/openssl.so/ext/win32/include/openssl/e_os2.h +315 -0
  1056. data/lib/extensions/openssl.so/ext/win32/include/openssl/ebcdic.h +19 -0
  1057. data/lib/extensions/openssl.so/ext/win32/include/openssl/ec.h +1159 -0
  1058. data/lib/extensions/openssl.so/ext/win32/include/openssl/ecdh.h +125 -0
  1059. data/lib/extensions/openssl.so/ext/win32/include/openssl/ecdsa.h +260 -0
  1060. data/lib/extensions/openssl.so/ext/win32/include/openssl/engine.h +842 -0
  1061. data/lib/extensions/openssl.so/ext/win32/include/openssl/err.h +386 -0
  1062. data/lib/extensions/openssl.so/ext/win32/include/openssl/evp.h +1402 -0
  1063. data/lib/extensions/openssl.so/ext/win32/include/openssl/hmac.h +110 -0
  1064. data/lib/extensions/openssl.so/ext/win32/include/openssl/idea.h +103 -0
  1065. data/lib/extensions/openssl.so/ext/win32/include/openssl/krb5_asn.h +256 -0
  1066. data/lib/extensions/openssl.so/ext/win32/include/openssl/kssl.h +183 -0
  1067. data/lib/extensions/openssl.so/ext/win32/include/openssl/lhash.h +241 -0
  1068. data/lib/extensions/openssl.so/ext/win32/include/openssl/md4.h +120 -0
  1069. data/lib/extensions/openssl.so/ext/win32/include/openssl/md5.h +120 -0
  1070. data/lib/extensions/openssl.so/ext/win32/include/openssl/mdc2.h +98 -0
  1071. data/lib/extensions/openssl.so/ext/win32/include/openssl/modes.h +135 -0
  1072. data/lib/extensions/openssl.so/ext/win32/include/openssl/obj_mac.h +4032 -0
  1073. data/lib/extensions/openssl.so/ext/win32/include/openssl/objects.h +1138 -0
  1074. data/lib/extensions/openssl.so/ext/win32/include/openssl/ocsp.h +623 -0
  1075. data/lib/extensions/openssl.so/ext/win32/include/openssl/opensslconf.h +235 -0
  1076. data/lib/extensions/openssl.so/ext/win32/include/openssl/opensslv.h +89 -0
  1077. data/lib/extensions/openssl.so/ext/win32/include/openssl/ossl_typ.h +202 -0
  1078. data/lib/extensions/openssl.so/ext/win32/include/openssl/pem.h +641 -0
  1079. data/lib/extensions/openssl.so/ext/win32/include/openssl/pem2.h +70 -0
  1080. data/lib/extensions/openssl.so/ext/win32/include/openssl/pkcs12.h +331 -0
  1081. data/lib/extensions/openssl.so/ext/win32/include/openssl/pkcs7.h +499 -0
  1082. data/lib/extensions/openssl.so/ext/win32/include/openssl/pqueue.h +94 -0
  1083. data/lib/extensions/openssl.so/ext/win32/include/openssl/rand.h +149 -0
  1084. data/lib/extensions/openssl.so/ext/win32/include/openssl/rc2.h +103 -0
  1085. data/lib/extensions/openssl.so/ext/win32/include/openssl/rc4.h +90 -0
  1086. data/lib/extensions/openssl.so/ext/win32/include/openssl/ripemd.h +107 -0
  1087. data/lib/extensions/openssl.so/ext/win32/include/openssl/rsa.h +582 -0
  1088. data/lib/extensions/openssl.so/ext/win32/include/openssl/safestack.h +2663 -0
  1089. data/lib/extensions/openssl.so/ext/win32/include/openssl/seed.h +139 -0
  1090. data/lib/extensions/openssl.so/ext/win32/include/openssl/sha.h +214 -0
  1091. data/lib/extensions/openssl.so/ext/win32/include/openssl/srp.h +172 -0
  1092. data/lib/extensions/openssl.so/ext/win32/include/openssl/srtp.h +145 -0
  1093. data/lib/extensions/openssl.so/ext/win32/include/openssl/ssl.h +2572 -0
  1094. data/lib/extensions/openssl.so/ext/win32/include/openssl/ssl2.h +272 -0
  1095. data/lib/extensions/openssl.so/ext/win32/include/openssl/ssl23.h +83 -0
  1096. data/lib/extensions/openssl.so/ext/win32/include/openssl/ssl3.h +678 -0
  1097. data/lib/extensions/openssl.so/ext/win32/include/openssl/stack.h +108 -0
  1098. data/lib/extensions/openssl.so/ext/win32/include/openssl/symhacks.h +477 -0
  1099. data/lib/extensions/openssl.so/ext/win32/include/openssl/tls1.h +735 -0
  1100. data/lib/extensions/openssl.so/ext/win32/include/openssl/ts.h +858 -0
  1101. data/lib/extensions/openssl.so/ext/win32/include/openssl/txt_db.h +112 -0
  1102. data/lib/extensions/openssl.so/ext/win32/include/openssl/ui.h +383 -0
  1103. data/lib/extensions/openssl.so/ext/win32/include/openssl/ui_compat.h +83 -0
  1104. data/lib/extensions/openssl.so/ext/win32/include/openssl/whrlpool.h +41 -0
  1105. data/lib/extensions/openssl.so/ext/win32/include/openssl/x509.h +1297 -0
  1106. data/lib/extensions/openssl.so/ext/win32/include/openssl/x509_vfy.h +567 -0
  1107. data/lib/extensions/openssl.so/ext/win32/include/openssl/x509v3.h +1007 -0
  1108. data/lib/extensions/openssl.so/ext/win32/lib/libeay32.lib +0 -0
  1109. data/lib/extensions/openssl.so/ext/win32/lib/ssleay32.lib +0 -0
  1110. data/lib/extensions/openssl.so/ext/wm/lib/libopenssl.lib +0 -0
  1111. data/lib/extensions/openssl.so/ext/wm/openssl.sln +30 -0
  1112. data/lib/extensions/openssl.so/ext/wm/openssl.vcproj +3254 -0
  1113. data/lib/extensions/openssl.so/ext/wm/tmp/MC3000c50b (ARMV4I)/Release/BuildLog.htm +0 -0
  1114. data/lib/extensions/openssl.so/ext/wm/tmp/Windows Mobile 6 Professional SDK (ARMV4I)/Release/BuildLog.htm +0 -0
  1115. data/lib/extensions/openssl.so/openssl.so.rb +1 -0
  1116. data/lib/extensions/openssl/ext.yml +2 -0
  1117. data/lib/extensions/openssl/ext/Rakefile +132 -0
  1118. data/lib/extensions/openssl/ext/android/extconf.h +55 -0
  1119. data/lib/extensions/openssl/ext/build +12 -0
  1120. data/lib/extensions/openssl/ext/build.bat +1 -0
  1121. data/lib/extensions/openssl/ext/extconf.rb +141 -0
  1122. data/lib/extensions/openssl/ext/iphone/Rakefile +79 -0
  1123. data/lib/extensions/openssl/ext/iphone/extconf.h +55 -0
  1124. data/lib/extensions/openssl/ext/iphone/openssl.xcodeproj/project.pbxproj +472 -0
  1125. data/lib/extensions/openssl/ext/iphone/openssl_Prefix.pch +7 -0
  1126. data/lib/extensions/openssl/ext/macosx/extconf.h +53 -0
  1127. data/lib/extensions/openssl/ext/openssl.sln +44 -0
  1128. data/lib/extensions/openssl/ext/openssl.vcproj +844 -0
  1129. data/lib/extensions/openssl/ext/openssl_missing.c +361 -0
  1130. data/lib/extensions/openssl/ext/openssl_missing.h +194 -0
  1131. data/lib/extensions/openssl/ext/ossl.c +514 -0
  1132. data/lib/extensions/openssl/ext/ossl.h +243 -0
  1133. data/lib/extensions/openssl/ext/ossl_asn1.c +1170 -0
  1134. data/lib/extensions/openssl/ext/ossl_asn1.h +59 -0
  1135. data/lib/extensions/openssl/ext/ossl_bio.c +86 -0
  1136. data/lib/extensions/openssl/ext/ossl_bio.h +21 -0
  1137. data/lib/extensions/openssl/ext/ossl_bn.c +852 -0
  1138. data/lib/extensions/openssl/ext/ossl_bn.h +25 -0
  1139. data/lib/extensions/openssl/ext/ossl_cipher.c +546 -0
  1140. data/lib/extensions/openssl/ext/ossl_cipher.h +22 -0
  1141. data/lib/extensions/openssl/ext/ossl_config.c +492 -0
  1142. data/lib/extensions/openssl/ext/ossl_config.h +22 -0
  1143. data/lib/extensions/openssl/ext/ossl_digest.c +257 -0
  1144. data/lib/extensions/openssl/ext/ossl_digest.h +22 -0
  1145. data/lib/extensions/openssl/ext/ossl_engine.c +411 -0
  1146. data/lib/extensions/openssl/ext/ossl_engine.h +20 -0
  1147. data/lib/extensions/openssl/ext/ossl_hmac.c +270 -0
  1148. data/lib/extensions/openssl/ext/ossl_hmac.h +19 -0
  1149. data/lib/extensions/openssl/ext/ossl_ns_spki.c +257 -0
  1150. data/lib/extensions/openssl/ext/ossl_ns_spki.h +21 -0
  1151. data/lib/extensions/openssl/ext/ossl_ocsp.c +773 -0
  1152. data/lib/extensions/openssl/ext/ossl_ocsp.h +24 -0
  1153. data/lib/extensions/openssl/ext/ossl_pkcs12.c +212 -0
  1154. data/lib/extensions/openssl/ext/ossl_pkcs12.h +15 -0
  1155. data/lib/extensions/openssl/ext/ossl_pkcs5.c +98 -0
  1156. data/lib/extensions/openssl/ext/ossl_pkcs5.h +6 -0
  1157. data/lib/extensions/openssl/ext/ossl_pkcs7.c +1041 -0
  1158. data/lib/extensions/openssl/ext/ossl_pkcs7.h +22 -0
  1159. data/lib/extensions/openssl/ext/ossl_pkey.c +240 -0
  1160. data/lib/extensions/openssl/ext/ossl_pkey.h +141 -0
  1161. data/lib/extensions/openssl/ext/ossl_pkey_dh.c +536 -0
  1162. data/lib/extensions/openssl/ext/ossl_pkey_dsa.c +492 -0
  1163. data/lib/extensions/openssl/ext/ossl_pkey_ec.c +1597 -0
  1164. data/lib/extensions/openssl/ext/ossl_pkey_rsa.c +601 -0
  1165. data/lib/extensions/openssl/ext/ossl_rand.c +202 -0
  1166. data/lib/extensions/openssl/ext/ossl_rand.h +20 -0
  1167. data/lib/extensions/openssl/ext/ossl_ssl.c +1691 -0
  1168. data/lib/extensions/openssl/ext/ossl_ssl.h +36 -0
  1169. data/lib/extensions/openssl/ext/ossl_ssl_session.c +306 -0
  1170. data/lib/extensions/openssl/ext/ossl_version.h +16 -0
  1171. data/lib/extensions/openssl/ext/ossl_x509.c +104 -0
  1172. data/lib/extensions/openssl/ext/ossl_x509.h +114 -0
  1173. data/lib/extensions/openssl/ext/ossl_x509attr.c +275 -0
  1174. data/lib/extensions/openssl/ext/ossl_x509cert.c +766 -0
  1175. data/lib/extensions/openssl/ext/ossl_x509crl.c +537 -0
  1176. data/lib/extensions/openssl/ext/ossl_x509ext.c +459 -0
  1177. data/lib/extensions/openssl/ext/ossl_x509name.c +375 -0
  1178. data/lib/extensions/openssl/ext/ossl_x509req.c +468 -0
  1179. data/lib/extensions/openssl/ext/ossl_x509revoked.c +229 -0
  1180. data/lib/extensions/openssl/ext/ossl_x509store.c +624 -0
  1181. data/lib/extensions/openssl/ext/ruby_missing.h +41 -0
  1182. data/lib/extensions/openssl/ext/windows/extconf.h +66 -0
  1183. data/lib/extensions/openssl/openssl.rb +24 -0
  1184. data/lib/extensions/openssl/openssl/bn.rb +35 -0
  1185. data/lib/extensions/openssl/openssl/buffering.rb +341 -0
  1186. data/lib/extensions/openssl/openssl/cipher.rb +65 -0
  1187. data/lib/extensions/openssl/openssl/digest.rb +61 -0
  1188. data/lib/extensions/openssl/openssl/ssl-internal.rb +178 -0
  1189. data/lib/extensions/openssl/openssl/ssl.rb +1 -0
  1190. data/lib/extensions/openssl/openssl/x509-internal.rb +153 -0
  1191. data/lib/extensions/openssl/openssl/x509.rb +1 -0
  1192. data/lib/extensions/rhoxml/rexml/xmldecl.rb +119 -0
  1193. data/lib/extensions/zlib/ext.yml +2 -0
  1194. data/lib/extensions/zlib/ext/README +115 -0
  1195. data/lib/extensions/zlib/ext/Rakefile +127 -0
  1196. data/lib/extensions/zlib/ext/adler32.c +179 -0
  1197. data/lib/extensions/zlib/ext/build +12 -0
  1198. data/lib/extensions/zlib/ext/build.bat +1 -0
  1199. data/lib/extensions/zlib/ext/compress.c +80 -0
  1200. data/lib/extensions/zlib/ext/crc32.c +425 -0
  1201. data/lib/extensions/zlib/ext/crc32.h +441 -0
  1202. data/lib/extensions/zlib/ext/deflate.c +1965 -0
  1203. data/lib/extensions/zlib/ext/deflate.h +346 -0
  1204. data/lib/extensions/zlib/ext/gzclose.c +25 -0
  1205. data/lib/extensions/zlib/ext/gzguts.h +193 -0
  1206. data/lib/extensions/zlib/ext/gzlib.c +620 -0
  1207. data/lib/extensions/zlib/ext/gzread.c +589 -0
  1208. data/lib/extensions/zlib/ext/gzwrite.c +565 -0
  1209. data/lib/extensions/zlib/ext/infback.c +640 -0
  1210. data/lib/extensions/zlib/ext/inffast.c +340 -0
  1211. data/lib/extensions/zlib/ext/inffast.h +11 -0
  1212. data/lib/extensions/zlib/ext/inffixed.h +94 -0
  1213. data/lib/extensions/zlib/ext/inflate.c +1496 -0
  1214. data/lib/extensions/zlib/ext/inflate.h +122 -0
  1215. data/lib/extensions/zlib/ext/inftrees.c +306 -0
  1216. data/lib/extensions/zlib/ext/inftrees.h +62 -0
  1217. data/lib/extensions/zlib/ext/iphone/Rakefile +79 -0
  1218. data/lib/extensions/zlib/ext/iphone/zlib.xcodeproj/project.pbxproj +360 -0
  1219. data/lib/extensions/zlib/ext/iphone/zlib_Prefix.pch +7 -0
  1220. data/lib/extensions/zlib/ext/trees.c +1224 -0
  1221. data/lib/extensions/zlib/ext/trees.h +128 -0
  1222. data/lib/extensions/zlib/ext/uncompr.c +59 -0
  1223. data/lib/extensions/zlib/ext/zconf.h +506 -0
  1224. data/lib/extensions/zlib/ext/zlib.c +3762 -0
  1225. data/lib/extensions/zlib/ext/zlib.h +1744 -0
  1226. data/lib/extensions/zlib/ext/zlib.sln +36 -0
  1227. data/lib/extensions/zlib/ext/zlib.vcproj +746 -0
  1228. data/lib/extensions/zlib/ext/zlib.vsprops +16 -0
  1229. data/lib/extensions/zlib/ext/zutil.c +324 -0
  1230. data/lib/extensions/zlib/ext/zutil.h +252 -0
  1231. data/lib/extensions/zlib/zlib.rb +0 -0
  1232. data/lib/framework/rbconfig.rb +1 -1
  1233. data/lib/framework/rho/render.rb +31 -34
  1234. data/lib/framework/rho/rho.rb +89 -24
  1235. data/lib/framework/rho/rhocontroller.rb +8 -5
  1236. data/lib/framework/rho/rhofsconnector.rb +3 -0
  1237. data/lib/framework/rhodes.rb +9 -9
  1238. data/lib/framework/rhom/rhom.rb +15 -0
  1239. data/lib/framework/rhom/rhom_db_adapter.rb +18 -0
  1240. data/lib/framework/rhom/rhom_object_factory.rb +36 -26
  1241. data/lib/framework/rhomotoapi.rb +65 -1
  1242. data/lib/framework/rhosystem.rb +23 -19
  1243. data/lib/framework/version.rb +7 -7
  1244. data/lib/rhodes.rb +9 -9
  1245. data/platform/android/Rhodes/AndroidManifest.xml +117 -117
  1246. data/platform/android/Rhodes/AndroidManifest.xml.erb +77 -0
  1247. data/platform/android/Rhodes/PushReceiver.erb +14 -0
  1248. data/platform/android/Rhodes/jni/Android.mk +3 -1
  1249. data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_Logger.h +16 -0
  1250. data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_RhodesService.h +8 -0
  1251. data/platform/android/Rhodes/jni/src/fileapi.cpp +18 -0
  1252. data/platform/android/Rhodes/jni/src/logger.cpp +16 -0
  1253. data/platform/android/Rhodes/jni/src/rhodesapp.cpp +9 -2
  1254. data/platform/android/Rhodes/jni/src/signature.cpp +3 -28
  1255. data/platform/android/Rhodes/src/com/rhomobile/rhodes/BaseActivity.java +41 -37
  1256. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Logger.java +5 -5
  1257. data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushReceiver.java +6 -2
  1258. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +38 -15
  1259. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesApplication.java +49 -9
  1260. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +130 -10
  1261. data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothManagerNew.java +13 -1
  1262. data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/Camera.java +8 -6
  1263. data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/CameraNewService.java +20 -0
  1264. data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/CameraOldService.java +5 -0
  1265. data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/CameraSemiService.java +14 -0
  1266. data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/CameraService.java +2 -0
  1267. data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/ImageCapture.java +16 -13
  1268. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/AbstractRhoExtension.java +1 -1
  1269. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/Config.java +3 -0
  1270. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/IRhoExtManager.java +1 -1
  1271. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/IRhoExtension.java +3 -1
  1272. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/RhoExtManager.java +10 -0
  1273. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/RhoExtManagerImpl.java +23 -35
  1274. data/platform/android/Rhodes/src/com/rhomobile/rhodes/file/RhoFileApi.java +10 -0
  1275. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SplashScreen.java +60 -34
  1276. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality.java +14 -1
  1277. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality01.java +38 -3
  1278. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality08.java +26 -4
  1279. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality11.java +47 -0
  1280. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionalityManager.java +4 -1
  1281. data/platform/android/Rhodes/src/com/rhomobile/rhodes/socket/RhoSocketImpl.java +9 -1
  1282. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/GoogleWebView.java +10 -0
  1283. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/IRhoWebView.java +2 -0
  1284. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebViewClient.java +10 -3
  1285. data/platform/android/build/RhodesSRC_build.files +1 -1
  1286. data/platform/android/build/android.rake +567 -556
  1287. data/platform/android/build/android_tools.rb +87 -0
  1288. data/platform/android/build/librhocommon_build.files +3 -0
  1289. data/platform/android/build/librhodb_build.files +2 -0
  1290. data/platform/android/build/manifest_generator.rb +96 -0
  1291. data/platform/bb/Hsqldb/src/org/hsqldb/Expression.java +2 -4
  1292. data/platform/bb/RubyVM/src/com/rho/RhoProfiler.java +11 -0
  1293. data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RhoSupport.java +61 -48
  1294. data/platform/bb/build/rhodes_build.files +0 -1
  1295. data/platform/bb/rhodes/platform/4.7/com/rho/rubyext/SignatureCapture.java +314 -0
  1296. data/platform/bb/rhodes/platform/common/com/rho/rubyext/SignatureCapture.java +312 -0
  1297. data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +4 -1
  1298. data/platform/iphone/Classes/AppManager/AppManager.h +1 -0
  1299. data/platform/iphone/Classes/AppManager/AppManager.m +165 -123
  1300. data/platform/iphone/Classes/Event/Event.m +53 -14
  1301. data/platform/iphone/Classes/Rhodes.h +5 -4
  1302. data/platform/iphone/Classes/Rhodes.m +10 -8
  1303. data/platform/iphone/Classes/Signature/SignatureDelegate.m +2 -2
  1304. data/platform/iphone/Classes/SimpleMainView.m +55 -17
  1305. data/platform/iphone/Classes/SplashViewController.m +28 -1
  1306. data/platform/iphone/Info.plist +59 -54
  1307. data/platform/iphone/RhoLib/RhoLib.xcodeproj/project.pbxproj +43 -14
  1308. data/platform/iphone/curl/curl.xcodeproj/project.pbxproj +15 -18
  1309. data/platform/iphone/rbuild/iphone.rake +113 -4
  1310. data/platform/iphone/rhoextlib/rhoextlib.xcodeproj/project.pbxproj +15 -17
  1311. data/platform/iphone/rhorubylib/rhorubylib.xcodeproj/project.pbxproj +6 -14
  1312. data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +20 -23
  1313. data/platform/iphone/rhosynclib/rhosynclib.xcodeproj/project.pbxproj +22 -14
  1314. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Frameworks/QtCore.framework/Versions/4/QtCore +0 -0
  1315. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Frameworks/QtGui.framework/Versions/4/QtGui +0 -0
  1316. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Frameworks/QtNetwork.framework/Versions/4/QtNetwork +0 -0
  1317. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Frameworks/QtWebKit.framework/Versions/4/QtWebKit +0 -0
  1318. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Info.plist +1 -1
  1319. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/MacOS/RhoSimulator +0 -0
  1320. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/accessible/libqtaccessiblewidgets.dylib +0 -0
  1321. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/bearer/libqcorewlanbearer.dylib +0 -0
  1322. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/bearer/libqgenericbearer.dylib +0 -0
  1323. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/codecs/libqcncodecs.dylib +0 -0
  1324. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/codecs/libqjpcodecs.dylib +0 -0
  1325. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/codecs/libqkrcodecs.dylib +0 -0
  1326. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/codecs/libqtwcodecs.dylib +0 -0
  1327. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/graphicssystems/libqtracegraphicssystem.dylib +0 -0
  1328. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/imageformats/libqgif.dylib +0 -0
  1329. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/imageformats/libqico.dylib +0 -0
  1330. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/imageformats/libqjpeg.dylib +0 -0
  1331. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/imageformats/libqmng.dylib +0 -0
  1332. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/imageformats/libqtga.dylib +0 -0
  1333. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/imageformats/libqtiff.dylib +0 -0
  1334. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/qmltooling/libqmldbg_inspector.dylib +0 -0
  1335. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/qmltooling/libqmldbg_tcp.dylib +0 -0
  1336. data/platform/osx/build/osx.rake +18 -9
  1337. data/platform/shared/RhoConnectClient/RhoConnectClient.cpp +12 -0
  1338. data/platform/shared/RhoConnectClient/RhoConnectClient.h +3 -0
  1339. data/platform/shared/common/Android.mk +1 -0
  1340. data/platform/shared/common/BundleManager.cpp +503 -47
  1341. data/platform/shared/common/ExtManager.h +4 -0
  1342. data/platform/shared/common/RhoSettingsDefs.h +3 -0
  1343. data/platform/shared/common/RhoStd.h +14 -1
  1344. data/platform/shared/common/RhodesApp.cpp +84 -137
  1345. data/platform/shared/common/RhodesApp.h +12 -7
  1346. data/platform/shared/common/RhodesAppBase.cpp +124 -2
  1347. data/platform/shared/common/RhodesAppBase.h +43 -2
  1348. data/platform/shared/common/ThreadQueue.cpp +1 -1
  1349. data/platform/shared/common/app_build_capabilities.h +0 -7
  1350. data/platform/shared/common/map/MapEngine.h +1 -0
  1351. data/platform/shared/common/push/IRhoPushClient.h +46 -0
  1352. data/platform/shared/common/push/RhoPushManager.cpp +146 -0
  1353. data/platform/shared/common/push/RhoPushManager.h +79 -0
  1354. data/platform/shared/curl/lib/curl_config.h +8 -0
  1355. data/platform/shared/curl/lib/netrc.c +2 -0
  1356. data/platform/shared/db/Android.mk +4 -1
  1357. data/platform/shared/db/DBAdapter.cpp +218 -12
  1358. data/platform/shared/db/DBAdapter.h +16 -1
  1359. data/platform/shared/db/DBAttrManager.cpp +18 -1
  1360. data/platform/shared/db/DBAttrManager.h +2 -1
  1361. data/platform/shared/db/DBImportTransaction.cpp +300 -0
  1362. data/platform/shared/db/DBImportTransaction.h +56 -0
  1363. data/platform/shared/db/DBRequestHelper.cpp +114 -0
  1364. data/platform/shared/db/DBRequestHelper.h +27 -0
  1365. data/platform/shared/logging/RhoLogConf.h +2 -0
  1366. data/platform/shared/net/AsyncHttp.cpp +4 -3
  1367. data/platform/shared/net/AsyncHttp.h +3 -2
  1368. data/platform/shared/net/CURLNetRequest.cpp +18 -5
  1369. data/platform/shared/net/HttpServer.cpp +18 -14
  1370. data/platform/shared/qt/rhodes/MainWindowCallback.h +0 -1
  1371. data/platform/shared/qt/rhodes/QtMainWindow.cpp +180 -36
  1372. data/platform/shared/qt/rhodes/QtMainWindow.h +13 -1
  1373. data/platform/shared/qt/rhodes/QtMainWindow.ui +22 -3
  1374. data/platform/shared/qt/rhodes/RhoSimulator.h +3 -0
  1375. data/platform/shared/qt/rhodes/impl/MainWindowImpl.cpp +22 -0
  1376. data/platform/shared/qt/rhodes/impl/MainWindowImpl.h +6 -0
  1377. data/platform/shared/qt/rhodes/impl/SystemImpl.cpp +15 -0
  1378. data/platform/shared/qt/rhodes/main.cpp +15 -1
  1379. data/platform/shared/qt/rholib/rholib.pro +8 -2
  1380. data/platform/shared/qt/syncengine/syncengine.pro +6 -2
  1381. data/platform/shared/ruby/ext/rho/extensions.c +2 -0
  1382. data/platform/shared/ruby/ext/rho/rhoruby.c +12 -0
  1383. data/platform/shared/ruby/ext/rho/rhoruby.h +2 -0
  1384. data/platform/shared/ruby/ext/rho/rhosupport.c +77 -38
  1385. data/platform/shared/ruby/ext/sqlite3_api/sqlite3_api_wrap.c +54 -2
  1386. data/platform/shared/ruby/ext/syncengine/syncengine.i +4 -0
  1387. data/platform/shared/ruby/ext/syncengine/syncengine_wrap.c +40 -1
  1388. data/platform/shared/ruby/ext/system/system.i +38 -4
  1389. data/platform/shared/ruby/ext/system/system_wrap.c +277 -9
  1390. data/platform/shared/ruby/iphone/ruby/config.h +28 -0
  1391. data/platform/shared/ruby/main.c +8 -0
  1392. data/platform/shared/ruby/wince/sys/timeb.c +4 -0
  1393. data/platform/shared/ruby/wince/sys/timeb.h +1 -0
  1394. data/platform/shared/rubyext/Android.mk +2 -1
  1395. data/platform/shared/rubyext/System.cpp +93 -3
  1396. data/platform/shared/rubyext/ZipFiles.cpp +65 -0
  1397. data/platform/shared/statistic/RhoProfiler.cpp +36 -6
  1398. data/platform/shared/statistic/RhoProfiler.h +3 -0
  1399. data/platform/shared/sync/ClientRegister.cpp +21 -5
  1400. data/platform/shared/sync/ClientRegister.h +4 -2
  1401. data/platform/shared/sync/ISyncProtocol.h +5 -2
  1402. data/platform/shared/sync/SyncEngine.cpp +85 -15
  1403. data/platform/shared/sync/SyncEngine.h +5 -0
  1404. data/platform/shared/sync/SyncNotify.cpp +3 -0
  1405. data/platform/shared/sync/SyncProtocol_3.h +14 -2
  1406. data/platform/shared/sync/SyncSource.cpp +238 -40
  1407. data/platform/shared/sync/SyncSource.h +2 -0
  1408. data/platform/shared/sync/SyncThread.cpp +7 -0
  1409. data/platform/shared/sync/SyncThread.h +1 -0
  1410. data/platform/shared/tcmalloc/rhomem.h +1 -1
  1411. data/platform/shared/tcmalloc/windows/port.cpp +1 -1
  1412. data/platform/shared/unzip/Android.mk +1 -1
  1413. data/platform/shared/unzip/zip.cpp +2953 -0
  1414. data/platform/shared/unzip/zip.h +255 -0
  1415. data/platform/win32/RhoSimulator/QtCore4.dll +0 -0
  1416. data/platform/win32/RhoSimulator/QtGui4.dll +0 -0
  1417. data/platform/win32/RhoSimulator/QtNetwork4.dll +0 -0
  1418. data/platform/win32/RhoSimulator/QtWebKit4.dll +0 -0
  1419. data/platform/win32/RhoSimulator/RhoSimulator.exe +0 -0
  1420. data/platform/win32/RhoSimulator/imageformats/qgif4.dll +0 -0
  1421. data/platform/win32/RhoSimulator/imageformats/qico4.dll +0 -0
  1422. data/platform/win32/RhoSimulator/imageformats/qjpeg4.dll +0 -0
  1423. data/platform/win32/RhoSimulator/imageformats/qmng4.dll +0 -0
  1424. data/platform/win32/RhoSimulator/imageformats/qsvg4.dll +0 -0
  1425. data/platform/win32/RhoSimulator/imageformats/qtiff4.dll +0 -0
  1426. data/platform/win32/RhoSimulator/phonon4.dll +0 -0
  1427. data/platform/win32/RubyWin/RubyWin.sln +2 -2
  1428. data/platform/win32/RubyWin/RubyWin.vcproj +6 -7
  1429. data/platform/wm/RhoLib/RhoLib.vcproj +33 -3
  1430. data/platform/wm/build/rhodes.nsi +64 -230
  1431. data/platform/wm/build/wm.rake +306 -93
  1432. data/platform/wm/rhodes.sln +70 -21
  1433. data/platform/wm/rhodes/DateTimePicker.h +1 -1
  1434. data/platform/wm/rhodes/IEBrowserEngine.cpp +4 -1
  1435. data/platform/wm/rhodes/MainWindow.cpp +8 -7
  1436. data/platform/wm/rhodes/MainWindow.h +1 -1
  1437. data/platform/wm/rhodes/RhoNativeViewManager.cpp +2 -2
  1438. data/platform/wm/rhodes/Rhodes.cpp +80 -30
  1439. data/platform/wm/rhodes/camera/Camera.cpp +44 -65
  1440. data/platform/wm/rhodes/camera/Camera.h +6 -0
  1441. data/platform/wm/rhodes/rho/common/ExtManager.cpp +29 -6
  1442. data/platform/wm/rhodes/rho/common/RhoClassFactory.cpp +6 -1
  1443. data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +3 -0
  1444. data/platform/wm/rhodes/rho/net/NetRequestImpl.h +1 -1
  1445. data/platform/wm/rhodes/rho/rubyext/NativeToolbarExt.cpp +5 -5
  1446. data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +188 -29
  1447. data/platform/wm/rhodes/rho/rubyext/WebView.cpp +3 -3
  1448. data/platform/wm/rhodes/rhodes.vcproj +2284 -148
  1449. data/platform/wm/rhodes/simulator/MainWindowQt.cpp +48 -10
  1450. data/platform/wm/rhodes/simulator/MainWindowQt.h +6 -2
  1451. data/platform/wm/rhoelements.sln +122 -0
  1452. data/platform/wm/rubylib/rubylib.vcproj +4 -2
  1453. data/platform/wm/sqlite3/sqlite3.vcproj +4 -2
  1454. data/platform/wm/syncengine/syncengine.vcproj +20 -2
  1455. data/platform/wm/tcmalloc/tcmalloc.vcproj +160 -0
  1456. data/platform/wp7/RhoRubyLib/rubyext/RhoSyncEngine.cs +4 -0
  1457. data/platform/wp7/RhoRubyLib/rubyext/RhoSystem.cs +4 -0
  1458. data/rakefile.rb +173 -17
  1459. data/res/build-tools/license_rc.dll +0 -0
  1460. data/res/build-tools/win32/license_rc.dll +0 -0
  1461. data/res/generators/templates/application/app/layout.erb +7 -3
  1462. data/res/generators/templates/application/public/css/re_webkit.css +1 -1
  1463. data/res/generators/templates/application/public/css/re_webkit_flat.css +753 -0
  1464. data/res/generators/templates/extension/extensions/montana/ext/montana/platform/iphone/Montana.xcodeproj/project.pbxproj +4 -10
  1465. data/spec/framework_spec/app/spec/core/file/new_spec.rb +2 -2
  1466. data/spec/framework_spec/app/spec/core/file/open_spec.rb +6 -6
  1467. data/spec/framework_spec/app/spec/core/file/shared/open.rb +1 -1
  1468. data/spec/framework_spec/app/spec/core/file/shared/stat.rb +2 -2
  1469. data/spec/framework_spec/app/spec/core/file/stat/blksize_spec.rb +1 -1
  1470. data/spec/framework_spec/app/spec/core/file/stat/blocks_spec.rb +1 -1
  1471. data/spec/framework_spec/app/spec/core/file/stat/comparison_spec.rb +1 -1
  1472. data/spec/framework_spec/app/spec/core/file/stat/ino_spec.rb +1 -1
  1473. data/spec/framework_spec/app/spec/core/file/stat/inspect_spec.rb +1 -1
  1474. data/spec/framework_spec/app/spec/core/file/stat/mode_spec.rb +1 -1
  1475. data/spec/framework_spec/app/spec/core/file/stat/nlink_spec.rb +1 -1
  1476. data/spec/framework_spec/app/spec/core/file/stat_spec.rb +1 -1
  1477. data/spec/framework_spec/app/spec/core/file/sticky_spec.rb +2 -2
  1478. data/spec/framework_spec/app/spec/core/io/close_read_spec.rb +1 -1
  1479. data/spec/framework_spec/app/spec/core/io/close_write_spec.rb +1 -1
  1480. data/spec/framework_spec/app/spec/core/io/foreach_spec.rb +8 -8
  1481. data/spec/framework_spec/app/spec/core/io/getc_spec.rb +1 -1
  1482. data/spec/framework_spec/app/spec/core/io/gets_spec.rb +1 -1
  1483. data/spec/framework_spec/app/spec/core/io/stat_spec.rb +1 -1
  1484. data/spec/framework_spec/app/spec/core/kernel/respond_to_spec.rb +1 -1
  1485. data/spec/framework_spec/app/spec/core/time/shared/gmt_offset.rb +1 -1
  1486. data/spec/framework_spec/app/spec/library/digest/hmac_spec.rb +91 -0
  1487. data/spec/framework_spec/app/spec/library/digest/md5/file_spec.rb +1 -1
  1488. data/spec/framework_spec/app/spec/library/digest/sha256/append_spec.rb +7 -0
  1489. data/spec/framework_spec/app/spec/library/digest/sha256/block_length_spec.rb +12 -0
  1490. data/spec/framework_spec/app/spec/library/digest/sha256/digest_bang_spec.rb +13 -0
  1491. data/spec/framework_spec/app/spec/library/digest/sha256/digest_length_spec.rb +12 -0
  1492. data/spec/framework_spec/app/spec/library/digest/sha256/digest_spec.rb +32 -0
  1493. data/spec/framework_spec/app/spec/library/digest/sha256/equal_spec.rb +37 -0
  1494. data/spec/framework_spec/app/spec/library/digest/sha256/file_spec.rb +47 -0
  1495. data/spec/framework_spec/app/spec/library/digest/sha256/hexdigest_bang_spec.rb +14 -0
  1496. data/spec/framework_spec/app/spec/library/digest/sha256/hexdigest_spec.rb +32 -0
  1497. data/spec/framework_spec/app/spec/library/digest/sha256/inspect_spec.rb +12 -0
  1498. data/spec/framework_spec/app/spec/library/digest/sha256/length_spec.rb +8 -0
  1499. data/spec/framework_spec/app/spec/library/digest/sha256/reset_spec.rb +15 -0
  1500. data/spec/framework_spec/app/spec/library/digest/sha256/shared/constants.rb +15 -0
  1501. data/spec/framework_spec/app/spec/library/digest/sha256/shared/length.rb +8 -0
  1502. data/spec/framework_spec/app/spec/library/digest/sha256/shared/update.rb +7 -0
  1503. data/spec/framework_spec/app/spec/library/digest/sha256/size_spec.rb +8 -0
  1504. data/spec/framework_spec/app/spec/library/digest/sha256/to_s_spec.rb +21 -0
  1505. data/spec/framework_spec/app/spec/library/digest/sha256/update_spec.rb +7 -0
  1506. data/spec/framework_spec/app/spec/library/digest/sha384/append_spec.rb +7 -0
  1507. data/spec/framework_spec/app/spec/library/digest/sha384/block_length_spec.rb +12 -0
  1508. data/spec/framework_spec/app/spec/library/digest/sha384/digest_bang_spec.rb +13 -0
  1509. data/spec/framework_spec/app/spec/library/digest/sha384/digest_length_spec.rb +12 -0
  1510. data/spec/framework_spec/app/spec/library/digest/sha384/digest_spec.rb +32 -0
  1511. data/spec/framework_spec/app/spec/library/digest/sha384/equal_spec.rb +37 -0
  1512. data/spec/framework_spec/app/spec/library/digest/sha384/file_spec.rb +47 -0
  1513. data/spec/framework_spec/app/spec/library/digest/sha384/hexdigest_bang_spec.rb +14 -0
  1514. data/spec/framework_spec/app/spec/library/digest/sha384/hexdigest_spec.rb +32 -0
  1515. data/spec/framework_spec/app/spec/library/digest/sha384/inspect_spec.rb +12 -0
  1516. data/spec/framework_spec/app/spec/library/digest/sha384/length_spec.rb +8 -0
  1517. data/spec/framework_spec/app/spec/library/digest/sha384/reset_spec.rb +15 -0
  1518. data/spec/framework_spec/app/spec/library/digest/sha384/shared/constants.rb +16 -0
  1519. data/spec/framework_spec/app/spec/library/digest/sha384/shared/length.rb +8 -0
  1520. data/spec/framework_spec/app/spec/library/digest/sha384/shared/update.rb +7 -0
  1521. data/spec/framework_spec/app/spec/library/digest/sha384/size_spec.rb +8 -0
  1522. data/spec/framework_spec/app/spec/library/digest/sha384/to_s_spec.rb +21 -0
  1523. data/spec/framework_spec/app/spec/library/digest/sha384/update_spec.rb +7 -0
  1524. data/spec/framework_spec/app/spec/library/digest/sha512/append_spec.rb +7 -0
  1525. data/spec/framework_spec/app/spec/library/digest/sha512/block_length_spec.rb +12 -0
  1526. data/spec/framework_spec/app/spec/library/digest/sha512/digest_bang_spec.rb +13 -0
  1527. data/spec/framework_spec/app/spec/library/digest/sha512/digest_length_spec.rb +12 -0
  1528. data/spec/framework_spec/app/spec/library/digest/sha512/digest_spec.rb +32 -0
  1529. data/spec/framework_spec/app/spec/library/digest/sha512/equal_spec.rb +37 -0
  1530. data/spec/framework_spec/app/spec/library/digest/sha512/file_spec.rb +47 -0
  1531. data/spec/framework_spec/app/spec/library/digest/sha512/hexdigest_bang_spec.rb +14 -0
  1532. data/spec/framework_spec/app/spec/library/digest/sha512/hexdigest_spec.rb +32 -0
  1533. data/spec/framework_spec/app/spec/library/digest/sha512/inspect_spec.rb +12 -0
  1534. data/spec/framework_spec/app/spec/library/digest/sha512/length_spec.rb +8 -0
  1535. data/spec/framework_spec/app/spec/library/digest/sha512/reset_spec.rb +15 -0
  1536. data/spec/framework_spec/app/spec/library/digest/sha512/shared/constants.rb +15 -0
  1537. data/spec/framework_spec/app/spec/library/digest/sha512/shared/length.rb +8 -0
  1538. data/spec/framework_spec/app/spec/library/digest/sha512/shared/update.rb +7 -0
  1539. data/spec/framework_spec/app/spec/library/digest/sha512/size_spec.rb +8 -0
  1540. data/spec/framework_spec/app/spec/library/digest/sha512/to_s_spec.rb +21 -0
  1541. data/spec/framework_spec/app/spec/library/digest/sha512/update_spec.rb +7 -0
  1542. data/spec/framework_spec/app/spec/library/ezcrypto/ezcrypto_spec.rb +13 -0
  1543. data/spec/framework_spec/app/spec/library/net/ftp/nlst_spec.rb +1 -1
  1544. data/spec/framework_spec/app/spec/library/net/ftp/retrbinary_spec.rb +1 -1
  1545. data/spec/framework_spec/app/spec/library/net/ftp/retrlines_spec.rb +1 -1
  1546. data/spec/framework_spec/app/spec/library/net/ftp/shared/getbinaryfile.rb +1 -1
  1547. data/spec/framework_spec/app/spec/library/net/ftp/shared/gettextfile.rb +1 -1
  1548. data/spec/framework_spec/app/spec/library/net/ftp/shared/list.rb +1 -1
  1549. data/spec/framework_spec/app/spec/library/net/ftp/shared/putbinaryfile.rb +1 -1
  1550. data/spec/framework_spec/app/spec/library/net/ftp/shared/puttextfile.rb +1 -1
  1551. data/spec/framework_spec/app/spec/library/net/ftp/storbinary_spec.rb +1 -1
  1552. data/spec/framework_spec/app/spec/library/net/ftp/storlines_spec.rb +1 -1
  1553. data/spec/framework_spec/app/spec/library/openssl/cipher_spec.rb +19 -0
  1554. data/spec/framework_spec/app/spec/library/openssl/config/freeze_spec.rb +21 -0
  1555. data/spec/framework_spec/app/spec/library/openssl/hmac/digest_spec.rb +18 -0
  1556. data/spec/framework_spec/app/spec/library/openssl/hmac/hexdigest_spec.rb +18 -0
  1557. data/spec/framework_spec/app/spec/library/openssl/random/pseudo_bytes_spec.rb +7 -0
  1558. data/spec/framework_spec/app/spec/library/openssl/random/random_bytes_spec.rb +7 -0
  1559. data/spec/framework_spec/app/spec/library/openssl/random/shared/random_bytes.rb +29 -0
  1560. data/spec/framework_spec/app/spec/library/openssl/shared/constants.rb +10 -0
  1561. data/spec/framework_spec/app/spec/library/zlib/adler32_spec.rb +46 -0
  1562. data/spec/framework_spec/app/spec/library/zlib/crc32_spec.rb +52 -0
  1563. data/spec/framework_spec/app/spec/library/zlib/crc_table_spec.rb +11 -0
  1564. data/spec/framework_spec/app/spec/library/zlib/deflate/append_spec.rb +1 -0
  1565. data/spec/framework_spec/app/spec/library/zlib/deflate/deflate_spec.rb +49 -0
  1566. data/spec/framework_spec/app/spec/library/zlib/deflate/flush_spec.rb +1 -0
  1567. data/spec/framework_spec/app/spec/library/zlib/deflate/initialize_copy_spec.rb +1 -0
  1568. data/spec/framework_spec/app/spec/library/zlib/deflate/new_spec.rb +1 -0
  1569. data/spec/framework_spec/app/spec/library/zlib/deflate/params_spec.rb +20 -0
  1570. data/spec/framework_spec/app/spec/library/zlib/deflate/set_dictionary_spec.rb +14 -0
  1571. data/spec/framework_spec/app/spec/library/zlib/gzipfile/close_spec.rb +23 -0
  1572. data/spec/framework_spec/app/spec/library/zlib/gzipfile/closed_spec.rb +17 -0
  1573. data/spec/framework_spec/app/spec/library/zlib/gzipfile/comment_spec.rb +27 -0
  1574. data/spec/framework_spec/app/spec/library/zlib/gzipfile/crc_spec.rb +1 -0
  1575. data/spec/framework_spec/app/spec/library/zlib/gzipfile/finish_spec.rb +1 -0
  1576. data/spec/framework_spec/app/spec/library/zlib/gzipfile/level_spec.rb +1 -0
  1577. data/spec/framework_spec/app/spec/library/zlib/gzipfile/mtime_spec.rb +1 -0
  1578. data/spec/framework_spec/app/spec/library/zlib/gzipfile/orig_name_spec.rb +27 -0
  1579. data/spec/framework_spec/app/spec/library/zlib/gzipfile/os_code_spec.rb +1 -0
  1580. data/spec/framework_spec/app/spec/library/zlib/gzipfile/sync_spec.rb +1 -0
  1581. data/spec/framework_spec/app/spec/library/zlib/gzipfile/to_io_spec.rb +1 -0
  1582. data/spec/framework_spec/app/spec/library/zlib/gzipfile/wrap_spec.rb +1 -0
  1583. data/spec/framework_spec/app/spec/library/zlib/gzipreader/each_byte_spec.rb +33 -0
  1584. data/spec/framework_spec/app/spec/library/zlib/gzipreader/each_line_spec.rb +1 -0
  1585. data/spec/framework_spec/app/spec/library/zlib/gzipreader/each_spec.rb +1 -0
  1586. data/spec/framework_spec/app/spec/library/zlib/gzipreader/eof_spec.rb +55 -0
  1587. data/spec/framework_spec/app/spec/library/zlib/gzipreader/getc_spec.rb +55 -0
  1588. data/spec/framework_spec/app/spec/library/zlib/gzipreader/gets_spec.rb +1 -0
  1589. data/spec/framework_spec/app/spec/library/zlib/gzipreader/lineno_spec.rb +1 -0
  1590. data/spec/framework_spec/app/spec/library/zlib/gzipreader/new_spec.rb +1 -0
  1591. data/spec/framework_spec/app/spec/library/zlib/gzipreader/open_spec.rb +1 -0
  1592. data/spec/framework_spec/app/spec/library/zlib/gzipreader/pos_spec.rb +26 -0
  1593. data/spec/framework_spec/app/spec/library/zlib/gzipreader/read_spec.rb +58 -0
  1594. data/spec/framework_spec/app/spec/library/zlib/gzipreader/readchar_spec.rb +1 -0
  1595. data/spec/framework_spec/app/spec/library/zlib/gzipreader/readline_spec.rb +1 -0
  1596. data/spec/framework_spec/app/spec/library/zlib/gzipreader/readlines_spec.rb +1 -0
  1597. data/spec/framework_spec/app/spec/library/zlib/gzipreader/rewind_spec.rb +47 -0
  1598. data/spec/framework_spec/app/spec/library/zlib/gzipreader/tell_spec.rb +1 -0
  1599. data/spec/framework_spec/app/spec/library/zlib/gzipreader/ungetc_spec.rb +1 -0
  1600. data/spec/framework_spec/app/spec/library/zlib/gzipreader/unused_spec.rb +1 -0
  1601. data/spec/framework_spec/app/spec/library/zlib/gzipwriter/append_spec.rb +1 -0
  1602. data/spec/framework_spec/app/spec/library/zlib/gzipwriter/comment_spec.rb +1 -0
  1603. data/spec/framework_spec/app/spec/library/zlib/gzipwriter/flush_spec.rb +1 -0
  1604. data/spec/framework_spec/app/spec/library/zlib/gzipwriter/mtime_spec.rb +41 -0
  1605. data/spec/framework_spec/app/spec/library/zlib/gzipwriter/new_spec.rb +1 -0
  1606. data/spec/framework_spec/app/spec/library/zlib/gzipwriter/open_spec.rb +1 -0
  1607. data/spec/framework_spec/app/spec/library/zlib/gzipwriter/orig_name_spec.rb +1 -0
  1608. data/spec/framework_spec/app/spec/library/zlib/gzipwriter/pos_spec.rb +1 -0
  1609. data/spec/framework_spec/app/spec/library/zlib/gzipwriter/print_spec.rb +1 -0
  1610. data/spec/framework_spec/app/spec/library/zlib/gzipwriter/printf_spec.rb +1 -0
  1611. data/spec/framework_spec/app/spec/library/zlib/gzipwriter/putc_spec.rb +1 -0
  1612. data/spec/framework_spec/app/spec/library/zlib/gzipwriter/puts_spec.rb +1 -0
  1613. data/spec/framework_spec/app/spec/library/zlib/gzipwriter/tell_spec.rb +1 -0
  1614. data/spec/framework_spec/app/spec/library/zlib/gzipwriter/write_spec.rb +24 -0
  1615. data/spec/framework_spec/app/spec/library/zlib/inflate/append_spec.rb +60 -0
  1616. data/spec/framework_spec/app/spec/library/zlib/inflate/inflate_spec.rb +109 -0
  1617. data/spec/framework_spec/app/spec/library/zlib/inflate/new_spec.rb +1 -0
  1618. data/spec/framework_spec/app/spec/library/zlib/inflate/set_dictionary_spec.rb +20 -0
  1619. data/spec/framework_spec/app/spec/library/zlib/inflate/sync_point_spec.rb +1 -0
  1620. data/spec/framework_spec/app/spec/library/zlib/inflate/sync_spec.rb +1 -0
  1621. data/spec/framework_spec/app/spec/library/zlib/zlib_version_spec.rb +1 -0
  1622. data/spec/framework_spec/app/spec/library/zlib/zstream/adler_spec.rb +1 -0
  1623. data/spec/framework_spec/app/spec/library/zlib/zstream/avail_in_spec.rb +1 -0
  1624. data/spec/framework_spec/app/spec/library/zlib/zstream/avail_out_spec.rb +1 -0
  1625. data/spec/framework_spec/app/spec/library/zlib/zstream/close_spec.rb +1 -0
  1626. data/spec/framework_spec/app/spec/library/zlib/zstream/closed_spec.rb +1 -0
  1627. data/spec/framework_spec/app/spec/library/zlib/zstream/data_type_spec.rb +1 -0
  1628. data/spec/framework_spec/app/spec/library/zlib/zstream/end_spec.rb +1 -0
  1629. data/spec/framework_spec/app/spec/library/zlib/zstream/ended_spec.rb +1 -0
  1630. data/spec/framework_spec/app/spec/library/zlib/zstream/finish_spec.rb +1 -0
  1631. data/spec/framework_spec/app/spec/library/zlib/zstream/finished_spec.rb +1 -0
  1632. data/spec/framework_spec/app/spec/library/zlib/zstream/flush_next_in_spec.rb +1 -0
  1633. data/spec/framework_spec/app/spec/library/zlib/zstream/flush_next_out_spec.rb +16 -0
  1634. data/spec/framework_spec/app/spec/library/zlib/zstream/reset_spec.rb +1 -0
  1635. data/spec/framework_spec/app/spec/library/zlib/zstream/stream_end_spec.rb +1 -0
  1636. data/spec/framework_spec/app/spec/library/zlib/zstream/total_in_spec.rb +1 -0
  1637. data/spec/framework_spec/app/spec/library/zlib/zstream/total_out_spec.rb +1 -0
  1638. data/spec/framework_spec/app/spec/shared/file/executable_real.rb +1 -1
  1639. data/spec/framework_spec/app/spec/shared/file/file.rb +1 -1
  1640. data/spec/framework_spec/app/spec_runner.rb +6 -5
  1641. data/spec/framework_spec/build.yml +4 -1
  1642. data/spec/phone_spec/app/BlobBulkTest/blob_bulk_test.png +0 -0
  1643. data/spec/phone_spec/app/BlobBulkTest/blob_bulk_test.rb +11 -0
  1644. data/spec/phone_spec/app/BlobBulkTest_s/blob_bulk_test_s.png +0 -0
  1645. data/spec/phone_spec/app/BlobBulkTest_s/blob_bulk_test_s.rb +11 -0
  1646. data/spec/phone_spec/app/Data/invalid_import_db.zip +0 -0
  1647. data/spec/phone_spec/app/Data/valid_import_db.zip +0 -0
  1648. data/spec/phone_spec/app/spec/asynchttp_spec.rb +1 -1
  1649. data/spec/phone_spec/app/spec/blob_bulksync_spec.rb +160 -0
  1650. data/spec/phone_spec/app/spec/bulksync_spec.rb +51 -1
  1651. data/spec/phone_spec/app/spec/bundle_update_spec.rb +85 -0
  1652. data/spec/phone_spec/app/spec/database_spec.rb +174 -0
  1653. data/spec/phone_spec/app/spec/events_spec.rb +4 -4
  1654. data/spec/phone_spec/app/spec/json_spec.rb +1 -1
  1655. data/spec/phone_spec/app/spec/rho_spec.rb +88 -12
  1656. data/spec/phone_spec/app/spec/rhofile_spec.rb +1 -1
  1657. data/spec/phone_spec/app/spec/rhom_object_spec.rb +8 -5
  1658. data/spec/phone_spec/app/spec/syncengine_spec.rb +281 -18
  1659. data/spec/phone_spec/app/spec/uri_spec.rb +5 -5
  1660. data/spec/phone_spec/app/spec_runner.rb +16 -9
  1661. data/spec/phone_spec/build.yml +2 -1
  1662. data/spec/phone_spec/public/file_for_replace.txt +1 -0
  1663. data/spec/phone_spec/public/file_to_remove.png +0 -0
  1664. data/spec/phone_spec/public/folder_to_remove.png +0 -0
  1665. data/spec/phone_spec/public/folder_to_remove/switch.png +0 -0
  1666. data/spec/phone_spec/public/partial_update_bundle/upgrade_bundle_partial.zip +0 -0
  1667. data/spec/phone_spec/upgrade_package_add_files.txt +2 -0
  1668. data/spec/phone_spec/upgrade_package_remove_files.txt +2 -0
  1669. data/version +1 -1
  1670. metadata +1384 -12
  1671. data/Manifest.txt +0 -8054
  1672. data/doc/alert-api.txt +0 -51
  1673. data/doc/files.txt +0 -4
  1674. data/doc/rhodes-api.txt +0 -147
  1675. data/doc/scanner.txt +0 -507
  1676. data/doc/timer-api.txt +0 -39
  1677. data/doc/tutorial.txt +0 -130
  1678. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/WebkitExtension.java +0 -53
@@ -150,6 +150,8 @@ public:
150
150
  String makeFileName(const CAttrValue& value);//throws Exception
151
151
  boolean downloadBlob(CAttrValue& value);//throws Exception
152
152
  boolean processBlob( const String& strCmd, const String& strObject, CAttrValue& oAttrValue );
153
+ boolean processAllBlobs();
154
+ boolean processServerBlobAttrs();
153
155
 
154
156
  void setRefreshTime( int nRefreshTime ){ m_nRefreshTime = nRefreshTime;}
155
157
 
@@ -511,6 +511,13 @@ void rho_sync_set_source_property(int nSrcID, const char* szPropName, const char
511
511
  CSyncEngine::getSourceOptions().setProperty(nSrcID, szPropName, szPropValue);
512
512
  }
513
513
 
514
+ #ifndef RHO_NO_RUBY
515
+ unsigned long rho_sync_get_source_property(int nSrcID, const char* szPropName)
516
+ {
517
+ return rho_ruby_create_string( CSyncEngine::getSourceOptions().getProperty(nSrcID, szPropName).c_str() );
518
+ }
519
+ #endif //RHO_NO_RUBY
520
+
514
521
  void rho_sync_set_ssl_verify_peer(int b)
515
522
  {
516
523
  CSyncThread::getSyncEngine().setSslVerifyPeer(b == 0 ? false : true);
@@ -203,6 +203,7 @@ void rho_sync_setobjectnotify_url_c(/*RHOC_CALLBACK*/void* callback, void* callb
203
203
 
204
204
  void rho_sync_stop();
205
205
  void rho_sync_set_source_property(int nSrcID, const char* szPropName, const char* szPropValue);
206
+ unsigned long rho_sync_get_source_property(int nSrcID, const char* szPropName);
206
207
  int rho_sync_issyncing();
207
208
 
208
209
  void rho_sync_enable_status_popup(int b);
@@ -6,7 +6,7 @@
6
6
  #endif //_CRT_SECURE_NO_DEPRECATE
7
7
 
8
8
  //#ifndef __APPLE__
9
- #if defined( REMOVE_WIN32_WCE ) || defined(REMOVE_WIN32)
9
+ #if defined( _WIN32_WCE ) && !defined(WCE_PLATFORM_MC3000C50B)
10
10
  #include <stdlib.h>
11
11
 
12
12
  #ifndef _RHO_NO_MEMDEFINES
@@ -226,7 +226,7 @@ extern void* TCMalloc_SystemAlloc(size_t size, size_t *actual_size,
226
226
  GlobalMemoryStatus(&sMemStat);
227
227
  sMemStat.dwAvailVirtual /= 1024;
228
228
 
229
- printf("TCMALLOC: VirtualAlloc = %d; Total: %d(Mb); Free VM: %d\n", size + extra, nTotal, sMemStat.dwAvailVirtual);
229
+ //printf("TCMALLOC: VirtualAlloc = %d; Total: %d(Mb); Free VM: %d\n", size + extra, nTotal, sMemStat.dwAvailVirtual);
230
230
 
231
231
  if (result == NULL)
232
232
  return NULL;
@@ -3,7 +3,7 @@ LOCAL_PATH := $(call my-dir)
3
3
  include $(CLEAR_VARS)
4
4
 
5
5
  LOCAL_MODULE := unzip
6
- LOCAL_SRC_FILES := unzip.cpp
6
+ LOCAL_SRC_FILES := unzip.cpp zip.cpp
7
7
  LOCAL_C_INCLUDES := $(SHARED_PATH_INC)
8
8
 
9
9
  include $(BUILD_STATIC_LIBRARY)
@@ -0,0 +1,2953 @@
1
+ #include "zip.h"
2
+ // THIS FILE is almost entirely based upon code by info-zip.
3
+ // It has been modified by Lucian Wischik. The modifications
4
+ // were a complete rewrite of the bit of code that generates the
5
+ // layout of the zipfile, and support for zipping to/from memory
6
+ // or handles or pipes or pagefile or diskfiles, encryption, unicode.
7
+ // The original code may be found at http://www.info-zip.org
8
+ // The original copyright text follows.
9
+ //
10
+ //
11
+ //
12
+ // This is version 1999-Oct-05 of the Info-ZIP copyright and license.
13
+ // The definitive version of this document should be available at
14
+ // ftp://ftp.cdrom.com/pub/infozip/license.html indefinitely.
15
+ //
16
+ // Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
17
+ //
18
+ // For the purposes of this copyright and license, "Info-ZIP" is defined as
19
+ // the following set of individuals:
20
+ //
21
+ // Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois,
22
+ // Jean-loup Gailly, Hunter Goatley, Ian Gorman, Chris Herborth, Dirk Haase,
23
+ // Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz, David Kirschbaum,
24
+ // Johnny Lee, Onno van der Linden, Igor Mandrichenko, Steve P. Miller,
25
+ // Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs, Kai Uwe Rommel,
26
+ // Steve Salisbury, Dave Smith, Christian Spieler, Antoine Verheijen,
27
+ // Paul von Behren, Rich Wales, Mike White
28
+ //
29
+ // This software is provided "as is," without warranty of any kind, express
30
+ // or implied. In no event shall Info-ZIP or its contributors be held liable
31
+ // for any direct, indirect, incidental, special or consequential damages
32
+ // arising out of the use of or inability to use this software.
33
+ //
34
+ // Permission is granted to anyone to use this software for any purpose,
35
+ // including commercial applications, and to alter it and redistribute it
36
+ // freely, subject to the following restrictions:
37
+ //
38
+ // 1. Redistributions of source code must retain the above copyright notice,
39
+ // definition, disclaimer, and this list of conditions.
40
+ //
41
+ // 2. Redistributions in binary form must reproduce the above copyright
42
+ // notice, definition, disclaimer, and this list of conditions in
43
+ // documentation and/or other materials provided with the distribution.
44
+ //
45
+ // 3. Altered versions--including, but not limited to, ports to new operating
46
+ // systems, existing ports with new graphical interfaces, and dynamic,
47
+ // shared, or static library versions--must be plainly marked as such
48
+ // and must not be misrepresented as being the original source. Such
49
+ // altered versions also must not be misrepresented as being Info-ZIP
50
+ // releases--including, but not limited to, labeling of the altered
51
+ // versions with the names "Info-ZIP" (or any variation thereof, including,
52
+ // but not limited to, different capitalizations), "Pocket UnZip," "WiZ"
53
+ // or "MacZip" without the explicit permission of Info-ZIP. Such altered
54
+ // versions are further prohibited from misrepresentative use of the
55
+ // Zip-Bugs or Info-ZIP e-mail addresses or of the Info-ZIP URL(s).
56
+ //
57
+ // 4. Info-ZIP retains the right to use the names "Info-ZIP," "Zip," "UnZip,"
58
+ // "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its own source and
59
+ // binary releases.
60
+ //
61
+
62
+
63
+ typedef unsigned char uch; // unsigned 8-bit value
64
+ typedef unsigned short ush; // unsigned 16-bit value
65
+ typedef unsigned long ulg; // unsigned 32-bit value
66
+ typedef size_t extent; // file size
67
+ typedef unsigned Pos; // must be at least 32 bits
68
+ typedef unsigned IPos; // A Pos is an index in the character window. Pos is used only for parameter passing
69
+
70
+ #ifndef EOF
71
+ #define EOF (-1)
72
+ #endif
73
+
74
+
75
+
76
+
77
+
78
+
79
+ // Error return values. The values 0..4 and 12..18 follow the conventions
80
+ // of PKZIP. The values 4..10 are all assigned to "insufficient memory"
81
+ // by PKZIP, so the codes 5..10 are used here for other purposes.
82
+ #define ZE_MISS -1 // used by procname(), zipbare()
83
+ #define ZE_OK 0 // success
84
+ #define ZE_EOF 2 // unexpected end of zip file
85
+ #define ZE_FORM 3 // zip file structure error
86
+ #define ZE_MEM 4 // out of memory
87
+ #define ZE_LOGIC 5 // internal logic error
88
+ #define ZE_BIG 6 // entry too large to split
89
+ #define ZE_NOTE 7 // invalid comment format
90
+ #define ZE_TEST 8 // zip test (-T) failed or out of memory
91
+ #define ZE_ABORT 9 // user interrupt or termination
92
+ #define ZE_TEMP 10 // error using a temp file
93
+ #define ZE_READ 11 // read or seek error
94
+ #define ZE_NONE 12 // nothing to do
95
+ #define ZE_NAME 13 // missing or empty zip file
96
+ #define ZE_WRITE 14 // error writing to a file
97
+ #define ZE_CREAT 15 // couldn't open to write
98
+ #define ZE_PARMS 16 // bad command line
99
+ #define ZE_OPEN 18 // could not open a specified file to read
100
+ #define ZE_MAXERR 18 // the highest error number
101
+
102
+
103
+ // internal file attribute
104
+ #define UNKNOWN (-1)
105
+ #define BINARY 0
106
+ #define ASCII 1
107
+
108
+ #define BEST -1 // Use best method (deflation or store)
109
+ #define STORE 0 // Store method
110
+ #define DEFLATE 8 // Deflation method
111
+
112
+ #define CRCVAL_INITIAL 0L
113
+
114
+ // MSDOS file or directory attributes
115
+ #define MSDOS_HIDDEN_ATTR 0x02
116
+ #define MSDOS_DIR_ATTR 0x10
117
+
118
+ // Lengths of headers after signatures in bytes
119
+ #define LOCHEAD 26
120
+ #define CENHEAD 42
121
+ #define ENDHEAD 18
122
+
123
+ // Definitions for extra field handling:
124
+ #define EB_HEADSIZE 4 /* length of a extra field block header */
125
+ #define EB_LEN 2 /* offset of data length field in header */
126
+ #define EB_UT_MINLEN 1 /* minimal UT field contains Flags byte */
127
+ #define EB_UT_FLAGS 0 /* byte offset of Flags field */
128
+ #define EB_UT_TIME1 1 /* byte offset of 1st time value */
129
+ #define EB_UT_FL_MTIME (1 << 0) /* mtime present */
130
+ #define EB_UT_FL_ATIME (1 << 1) /* atime present */
131
+ #define EB_UT_FL_CTIME (1 << 2) /* ctime present */
132
+ #define EB_UT_LEN(n) (EB_UT_MINLEN + 4 * (n))
133
+ #define EB_L_UT_SIZE (EB_HEADSIZE + EB_UT_LEN(3))
134
+ #define EB_C_UT_SIZE (EB_HEADSIZE + EB_UT_LEN(1))
135
+
136
+
137
+ // Macros for writing machine integers to little-endian format
138
+ #define PUTSH(a,f) {char _putsh_c=(char)((a)&0xff); wfunc(param,&_putsh_c,1); _putsh_c=(char)((a)>>8); wfunc(param,&_putsh_c,1);}
139
+ #define PUTLG(a,f) {PUTSH((a) & 0xffff,(f)) PUTSH((a) >> 16,(f))}
140
+
141
+
142
+ // -- Structure of a ZIP file --
143
+ // Signatures for zip file information headers
144
+ #define LOCSIG 0x04034b50L
145
+ #define CENSIG 0x02014b50L
146
+ #define ENDSIG 0x06054b50L
147
+ #define EXTLOCSIG 0x08074b50L
148
+
149
+
150
+ #define MIN_MATCH 3
151
+ #define MAX_MATCH 258
152
+ // The minimum and maximum match lengths
153
+
154
+
155
+ #define WSIZE (0x8000)
156
+ // Maximum window size = 32K. If you are really short of memory, compile
157
+ // with a smaller WSIZE but this reduces the compression ratio for files
158
+ // of size > WSIZE. WSIZE must be a power of two in the current implementation.
159
+ //
160
+
161
+ #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
162
+ // Minimum amount of lookahead, except at the end of the input file.
163
+ // See deflate.c for comments about the MIN_MATCH+1.
164
+ //
165
+
166
+ #define MAX_DIST (WSIZE-MIN_LOOKAHEAD)
167
+ // In order to simplify the code, particularly on 16 bit machines, match
168
+ // distances are limited to MAX_DIST instead of WSIZE.
169
+ //
170
+
171
+
172
+ #define ZIP_HANDLE 1
173
+ #define ZIP_FILENAME 2
174
+ #define ZIP_MEMORY 3
175
+ #define ZIP_FOLDER 4
176
+
177
+
178
+
179
+ // ===========================================================================
180
+ // Constants
181
+ //
182
+
183
+ #define MAX_BITS 15
184
+ // All codes must not exceed MAX_BITS bits
185
+
186
+ #define MAX_BL_BITS 7
187
+ // Bit length codes must not exceed MAX_BL_BITS bits
188
+
189
+ #define LENGTH_CODES 29
190
+ // number of length codes, not counting the special END_BLOCK code
191
+
192
+ #define LITERALS 256
193
+ // number of literal bytes 0..255
194
+
195
+ #define END_BLOCK 256
196
+ // end of block literal code
197
+
198
+ #define L_CODES (LITERALS+1+LENGTH_CODES)
199
+ // number of Literal or Length codes, including the END_BLOCK code
200
+
201
+ #define D_CODES 30
202
+ // number of distance codes
203
+
204
+ #define BL_CODES 19
205
+ // number of codes used to transfer the bit lengths
206
+
207
+
208
+ #define STORED_BLOCK 0
209
+ #define STATIC_TREES 1
210
+ #define DYN_TREES 2
211
+ // The three kinds of block type
212
+
213
+ #define LIT_BUFSIZE 0x8000
214
+ #define DIST_BUFSIZE LIT_BUFSIZE
215
+ // Sizes of match buffers for literals/lengths and distances. There are
216
+ // 4 reasons for limiting LIT_BUFSIZE to 64K:
217
+ // - frequencies can be kept in 16 bit counters
218
+ // - if compression is not successful for the first block, all input data is
219
+ // still in the window so we can still emit a stored block even when input
220
+ // comes from standard input. (This can also be done for all blocks if
221
+ // LIT_BUFSIZE is not greater than 32K.)
222
+ // - if compression is not successful for a file smaller than 64K, we can
223
+ // even emit a stored file instead of a stored block (saving 5 bytes).
224
+ // - creating new Huffman trees less frequently may not provide fast
225
+ // adaptation to changes in the input data statistics. (Take for
226
+ // example a binary file with poorly compressible code followed by
227
+ // a highly compressible string table.) Smaller buffer sizes give
228
+ // fast adaptation but have of course the overhead of transmitting trees
229
+ // more frequently.
230
+ // - I can't count above 4
231
+ // The current code is general and allows DIST_BUFSIZE < LIT_BUFSIZE (to save
232
+ // memory at the expense of compression). Some optimizations would be possible
233
+ // if we rely on DIST_BUFSIZE == LIT_BUFSIZE.
234
+ //
235
+
236
+ #define REP_3_6 16
237
+ // repeat previous bit length 3-6 times (2 bits of repeat count)
238
+
239
+ #define REPZ_3_10 17
240
+ // repeat a zero length 3-10 times (3 bits of repeat count)
241
+
242
+ #define REPZ_11_138 18
243
+ // repeat a zero length 11-138 times (7 bits of repeat count)
244
+
245
+ #define HEAP_SIZE (2*L_CODES+1)
246
+ // maximum heap size
247
+
248
+
249
+ // ===========================================================================
250
+ // Local data used by the "bit string" routines.
251
+ //
252
+
253
+ #define Buf_size (8 * 2*sizeof(char))
254
+ // Number of bits used within bi_buf. (bi_buf may be implemented on
255
+ // more than 16 bits on some systems.)
256
+
257
+ // Output a 16 bit value to the bit stream, lower (oldest) byte first
258
+ #define PUTSHORT(state,w) \
259
+ { if (state.bs.out_offset >= state.bs.out_size-1) \
260
+ state.flush_outbuf(state.param,state.bs.out_buf, &state.bs.out_offset); \
261
+ state.bs.out_buf[state.bs.out_offset++] = (char) ((w) & 0xff); \
262
+ state.bs.out_buf[state.bs.out_offset++] = (char) ((ush)(w) >> 8); \
263
+ }
264
+
265
+ #define PUTBYTE(state,b) \
266
+ { if (state.bs.out_offset >= state.bs.out_size) \
267
+ state.flush_outbuf(state.param,state.bs.out_buf, &state.bs.out_offset); \
268
+ state.bs.out_buf[state.bs.out_offset++] = (char) (b); \
269
+ }
270
+
271
+ // DEFLATE.CPP HEADER
272
+
273
+ #define HASH_BITS 15
274
+ // For portability to 16 bit machines, do not use values above 15.
275
+
276
+ #define HASH_SIZE (unsigned)(1<<HASH_BITS)
277
+ #define HASH_MASK (HASH_SIZE-1)
278
+ #define WMASK (WSIZE-1)
279
+ // HASH_SIZE and WSIZE must be powers of two
280
+
281
+ #define NIL 0
282
+ // Tail of hash chains
283
+
284
+ #define FAST 4
285
+ #define SLOW 2
286
+ // speed options for the general purpose bit flag
287
+
288
+ #define TOO_FAR 4096
289
+ // Matches of length 3 are discarded if their distance exceeds TOO_FAR
290
+
291
+
292
+
293
+ #define EQUAL 0
294
+ // result of memcmp for equal strings
295
+
296
+
297
+ // ===========================================================================
298
+ // Local data used by the "longest match" routines.
299
+
300
+ #define H_SHIFT ((HASH_BITS+MIN_MATCH-1)/MIN_MATCH)
301
+ // Number of bits by which ins_h and del_h must be shifted at each
302
+ // input step. It must be such that after MIN_MATCH steps, the oldest
303
+ // byte no longer takes part in the hash key, that is:
304
+ // H_SHIFT * MIN_MATCH >= HASH_BITS
305
+
306
+ #define max_insert_length max_lazy_match
307
+ // Insert new strings in the hash table only if the match length
308
+ // is not greater than this length. This saves time but degrades compression.
309
+ // max_insert_length is used only for compression levels <= 3.
310
+
311
+
312
+
313
+ const int extra_lbits[LENGTH_CODES] // extra bits for each length code
314
+ = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
315
+
316
+ const int extra_dbits[D_CODES] // extra bits for each distance code
317
+ = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
318
+
319
+ const int extra_blbits[BL_CODES]// extra bits for each bit length code
320
+ = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
321
+
322
+ const uch bl_order[BL_CODES] = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
323
+ // The lengths of the bit length codes are sent in order of decreasing
324
+ // probability, to avoid transmitting the lengths for unused bit length codes.
325
+
326
+
327
+ typedef struct config {
328
+ ush good_length; // reduce lazy search above this match length
329
+ ush max_lazy; // do not perform lazy search above this match length
330
+ ush nice_length; // quit search above this match length
331
+ ush max_chain;
332
+ } config;
333
+
334
+ // Values for max_lazy_match, good_match, nice_match and max_chain_length,
335
+ // depending on the desired pack level (0..9). The values given below have
336
+ // been tuned to exclude worst case performance for pathological files.
337
+ // Better values may be found for specific files.
338
+ //
339
+
340
+ const config configuration_table[10] = {
341
+ // good lazy nice chain
342
+ {0, 0, 0, 0}, // 0 store only
343
+ {4, 4, 8, 4}, // 1 maximum speed, no lazy matches
344
+ {4, 5, 16, 8}, // 2
345
+ {4, 6, 32, 32}, // 3
346
+ {4, 4, 16, 16}, // 4 lazy matches */
347
+ {8, 16, 32, 32}, // 5
348
+ {8, 16, 128, 128}, // 6
349
+ {8, 32, 128, 256}, // 7
350
+ {32, 128, 258, 1024}, // 8
351
+ {32, 258, 258, 4096}};// 9 maximum compression */
352
+
353
+ // Note: the deflate() code requires max_lazy >= MIN_MATCH and max_chain >= 4
354
+ // For deflate_fast() (levels <= 3) good is ignored and lazy has a different meaning.
355
+
356
+
357
+
358
+
359
+
360
+
361
+
362
+ // Data structure describing a single value and its code string.
363
+ typedef struct ct_data {
364
+ union {
365
+ ush freq; // frequency count
366
+ ush code; // bit string
367
+ } fc;
368
+ union {
369
+ ush dad; // father node in Huffman tree
370
+ ush len; // length of bit string
371
+ } dl;
372
+ } ct_data;
373
+
374
+ typedef struct tree_desc {
375
+ ct_data *dyn_tree; // the dynamic tree
376
+ ct_data *static_tree; // corresponding static tree or NULL
377
+ const int *extra_bits; // extra bits for each code or NULL
378
+ int extra_base; // base index for extra_bits
379
+ int elems; // max number of elements in the tree
380
+ int max_length; // max bit length for the codes
381
+ int max_code; // largest code with non zero frequency
382
+ } tree_desc;
383
+
384
+
385
+
386
+
387
+ class TTreeState
388
+ { public:
389
+ TTreeState();
390
+
391
+ ct_data dyn_ltree[HEAP_SIZE]; // literal and length tree
392
+ ct_data dyn_dtree[2*D_CODES+1]; // distance tree
393
+ ct_data static_ltree[L_CODES+2]; // the static literal tree...
394
+ // ... Since the bit lengths are imposed, there is no need for the L_CODES
395
+ // extra codes used during heap construction. However the codes 286 and 287
396
+ // are needed to build a canonical tree (see ct_init below).
397
+ ct_data static_dtree[D_CODES]; // the static distance tree...
398
+ // ... (Actually a trivial tree since all codes use 5 bits.)
399
+ ct_data bl_tree[2*BL_CODES+1]; // Huffman tree for the bit lengths
400
+
401
+ tree_desc l_desc;
402
+ tree_desc d_desc;
403
+ tree_desc bl_desc;
404
+
405
+ ush bl_count[MAX_BITS+1]; // number of codes at each bit length for an optimal tree
406
+
407
+ int heap[2*L_CODES+1]; // heap used to build the Huffman trees
408
+ int heap_len; // number of elements in the heap
409
+ int heap_max; // element of largest frequency
410
+ // The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
411
+ // The same heap array is used to build all trees.
412
+
413
+ uch depth[2*L_CODES+1];
414
+ // Depth of each subtree used as tie breaker for trees of equal frequency
415
+
416
+ uch length_code[MAX_MATCH-MIN_MATCH+1];
417
+ // length code for each normalized match length (0 == MIN_MATCH)
418
+
419
+ uch dist_code[512];
420
+ // distance codes. The first 256 values correspond to the distances
421
+ // 3 .. 258, the last 256 values correspond to the top 8 bits of
422
+ // the 15 bit distances.
423
+
424
+ int base_length[LENGTH_CODES];
425
+ // First normalized length for each code (0 = MIN_MATCH)
426
+
427
+ int base_dist[D_CODES];
428
+ // First normalized distance for each code (0 = distance of 1)
429
+
430
+ uch l_buf[LIT_BUFSIZE]; // buffer for literals/lengths
431
+ ush d_buf[DIST_BUFSIZE]; // buffer for distances
432
+
433
+ uch flag_buf[(LIT_BUFSIZE/8)];
434
+ // flag_buf is a bit array distinguishing literals from lengths in
435
+ // l_buf, and thus indicating the presence or absence of a distance.
436
+
437
+ unsigned last_lit; // running index in l_buf
438
+ unsigned last_dist; // running index in d_buf
439
+ unsigned last_flags; // running index in flag_buf
440
+ uch flags; // current flags not yet saved in flag_buf
441
+ uch flag_bit; // current bit used in flags
442
+ // bits are filled in flags starting at bit 0 (least significant).
443
+ // Note: these flags are overkill in the current code since we don't
444
+ // take advantage of DIST_BUFSIZE == LIT_BUFSIZE.
445
+
446
+ ulg opt_len; // bit length of current block with optimal trees
447
+ ulg static_len; // bit length of current block with static trees
448
+
449
+ ulg cmpr_bytelen; // total byte length of compressed file
450
+ ulg cmpr_len_bits; // number of bits past 'cmpr_bytelen'
451
+
452
+ ulg input_len; // total byte length of input file
453
+ // input_len is for debugging only since we can get it by other means.
454
+
455
+ ush *file_type; // pointer to UNKNOWN, BINARY or ASCII
456
+ // int *file_method; // pointer to DEFLATE or STORE
457
+ };
458
+
459
+ TTreeState::TTreeState()
460
+ { tree_desc a = {dyn_ltree, static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS, 0}; l_desc = a;
461
+ tree_desc b = {dyn_dtree, static_dtree, extra_dbits, 0, D_CODES, MAX_BITS, 0}; d_desc = b;
462
+ tree_desc c = {bl_tree, NULL, extra_blbits, 0, BL_CODES, MAX_BL_BITS, 0}; bl_desc = c;
463
+ last_lit=0;
464
+ last_dist=0;
465
+ last_flags=0;
466
+ }
467
+
468
+
469
+
470
+ class TBitState
471
+ { public:
472
+
473
+ int flush_flg;
474
+ //
475
+ unsigned bi_buf;
476
+ // Output buffer. bits are inserted starting at the bottom (least significant
477
+ // bits). The width of bi_buf must be at least 16 bits.
478
+ int bi_valid;
479
+ // Number of valid bits in bi_buf. All bits above the last valid bit
480
+ // are always zero.
481
+ char *out_buf;
482
+ // Current output buffer.
483
+ unsigned out_offset;
484
+ // Current offset in output buffer.
485
+ // On 16 bit machines, the buffer is limited to 64K.
486
+ unsigned out_size;
487
+ // Size of current output buffer
488
+ ulg bits_sent; // bit length of the compressed data only needed for debugging???
489
+ };
490
+
491
+
492
+
493
+
494
+
495
+
496
+
497
+ class TDeflateState
498
+ { public:
499
+ TDeflateState() {window_size=0;}
500
+
501
+ uch window[2L*WSIZE];
502
+ // Sliding window. Input bytes are read into the second half of the window,
503
+ // and move to the first half later to keep a dictionary of at least WSIZE
504
+ // bytes. With this organization, matches are limited to a distance of
505
+ // WSIZE-MAX_MATCH bytes, but this ensures that IO is always
506
+ // performed with a length multiple of the block size. Also, it limits
507
+ // the window size to 64K, which is quite useful on MSDOS.
508
+ // To do: limit the window size to WSIZE+CBSZ if SMALL_MEM (the code would
509
+ // be less efficient since the data would have to be copied WSIZE/CBSZ times)
510
+ Pos prev[WSIZE];
511
+ // Link to older string with same hash index. To limit the size of this
512
+ // array to 64K, this link is maintained only for the last 32K strings.
513
+ // An index in this array is thus a window index modulo 32K.
514
+ Pos head[HASH_SIZE];
515
+ // Heads of the hash chains or NIL. If your compiler thinks that
516
+ // HASH_SIZE is a dynamic value, recompile with -DDYN_ALLOC.
517
+
518
+ ulg window_size;
519
+ // window size, 2*WSIZE except for MMAP or BIG_MEM, where it is the
520
+ // input file length plus MIN_LOOKAHEAD.
521
+
522
+ long block_start;
523
+ // window position at the beginning of the current output block. Gets
524
+ // negative when the window is moved backwards.
525
+
526
+ int sliding;
527
+ // Set to false when the input file is already in memory
528
+
529
+ unsigned ins_h; // hash index of string to be inserted
530
+
531
+ unsigned int prev_length;
532
+ // Length of the best match at previous step. Matches not greater than this
533
+ // are discarded. This is used in the lazy match evaluation.
534
+
535
+ unsigned strstart; // start of string to insert
536
+ unsigned match_start; // start of matching string
537
+ int eofile; // flag set at end of input file
538
+ unsigned lookahead; // number of valid bytes ahead in window
539
+
540
+ unsigned max_chain_length;
541
+ // To speed up deflation, hash chains are never searched beyond this length.
542
+ // A higher limit improves compression ratio but degrades the speed.
543
+
544
+ unsigned int max_lazy_match;
545
+ // Attempt to find a better match only when the current match is strictly
546
+ // smaller than this value. This mechanism is used only for compression
547
+ // levels >= 4.
548
+
549
+ unsigned good_match;
550
+ // Use a faster search when the previous match is longer than this
551
+
552
+ int nice_match; // Stop searching when current match exceeds this
553
+ };
554
+
555
+ typedef long lutime_t; // define it ourselves since we don't include time.h
556
+
557
+ typedef struct iztimes {
558
+ lutime_t atime,mtime,ctime;
559
+ } iztimes; // access, modify, create times
560
+
561
+ typedef struct zlist {
562
+ ush vem, ver, flg, how; // See central header in zipfile.c for what vem..off are
563
+ ulg tim, crc, siz, len;
564
+ extent nam, ext, cext, com; // offset of ext must be >= LOCHEAD
565
+ ush dsk, att, lflg; // offset of lflg must be >= LOCHEAD
566
+ ulg atx, off;
567
+ char name[MAX_PATH]; // File name in zip file
568
+ char *extra; // Extra field (set only if ext != 0)
569
+ char *cextra; // Extra in central (set only if cext != 0)
570
+ char *comment; // Comment (set only if com != 0)
571
+ char iname[MAX_PATH]; // Internal file name after cleanup
572
+ char zname[MAX_PATH]; // External version of internal name
573
+ int mark; // Marker for files to operate on
574
+ int trash; // Marker for files to delete
575
+ int dosflag; // Set to force MSDOS file attributes
576
+ struct zlist *nxt; // Pointer to next header in list
577
+ } TZipFileInfo;
578
+
579
+
580
+ struct TState;
581
+ typedef unsigned (*READFUNC)(TState &state, char *buf,unsigned size);
582
+ typedef unsigned (*FLUSHFUNC)(void *param, const char *buf, unsigned *size);
583
+ typedef unsigned (*WRITEFUNC)(void *param, const char *buf, unsigned size);
584
+ struct TState
585
+ { void *param;
586
+ int level; bool seekable;
587
+ READFUNC readfunc; FLUSHFUNC flush_outbuf;
588
+ TTreeState ts; TBitState bs; TDeflateState ds;
589
+ const char *err;
590
+ };
591
+
592
+
593
+
594
+
595
+ // ----------------------------------------------------------------------
596
+ // some windows<->linux portability things
597
+ #ifdef ZIP_STD
598
+ void filetime2dosdatetime(const FILETIME ft, WORD *dosdate, WORD *dostime)
599
+ { struct tm *st=gmtime(&ft);
600
+ *dosdate = (ush)(((st->tm_year+1900 -1980)&0x7f) << 9);
601
+ *dosdate |= (ush)((st->tm_mon&0xf) << 5);
602
+ *dosdate |= (ush)((st->tm_mday&0x1f));
603
+ *dostime = (ush)((st->tm_hour&0x1f) << 11);
604
+ *dostime |= (ush)((st->tm_min&0x3f) << 5);
605
+ *dostime |= (ush)((st->tm_sec*2)&0x1f);
606
+ }
607
+
608
+ void GetNow(lutime_t *ft, WORD *dosdate, WORD *dostime)
609
+ { time_t tm = time(0);
610
+ filetime2dosdatetime(tm,dosdate,dostime);
611
+ *ft = (lutime_t)tm;
612
+ }
613
+
614
+ DWORD GetFilePosZ(HANDLE hfout)
615
+ { struct stat st; fstat(fileno(hfout),&st);
616
+ if ((st.st_mode&S_IFREG)==0) return 0xFFFFFFFF;
617
+ return ftell(hfout);
618
+ }
619
+
620
+ ZRESULT GetFileInfo(FILE *hf, ulg *attr, long *size, iztimes *times, ulg *timestamp)
621
+ { // The handle must be a handle to a file
622
+ // The date and time is returned in a long with the date most significant to allow
623
+ // unsigned integer comparison of absolute times. The attributes have two
624
+ // high bytes unix attr, and two low bytes a mapping of that to DOS attr.
625
+ struct stat bhi; int res=fstat(fileno(hf),&bhi); if (res==-1) return ZR_NOFILE;
626
+ ulg fa=bhi.st_mode; ulg a=0;
627
+ // Zip uses the lower word for its interpretation of windows stuff
628
+ if ((fa&S_IWUSR)==0) a|=0x01;
629
+ if (S_ISDIR(fa)) a|=0x10;
630
+ // It uses the upper word for standard unix attr
631
+ a |= ((fa&0xFFFF)<<16);
632
+ //
633
+ if (attr!=NULL) *attr = a;
634
+ if (size!=NULL) *size = bhi.st_size;
635
+ if (times!=NULL)
636
+ { times->atime = (lutime_t)bhi.st_atime;
637
+ times->mtime = (lutime_t)bhi.st_mtime;
638
+ times->ctime = (lutime_t)bhi.st_ctime;
639
+ }
640
+ if (timestamp!=NULL)
641
+ { ush dosdate,dostime;
642
+ filetime2dosdatetime(bhi.st_mtime,&dosdate,&dostime);
643
+ *timestamp = (ush)dostime | (((ulg)dosdate)<<16);
644
+ }
645
+ return ZR_OK;
646
+ }
647
+
648
+
649
+ // ----------------------------------------------------------------------
650
+ #else
651
+ void filetime2dosdatetime(const FILETIME ft, WORD *dosdate,WORD *dostime)
652
+ { // date: bits 0-4 are day of month 1-31. Bits 5-8 are month 1..12. Bits 9-15 are year-1980
653
+ // time: bits 0-4 are seconds/2, bits 5-10 are minute 0..59. Bits 11-15 are hour 0..23
654
+ SYSTEMTIME st; FileTimeToSystemTime(&ft,&st);
655
+ *dosdate = (WORD)(((st.wYear-1980)&0x7f) << 9);
656
+ *dosdate |= (WORD)((st.wMonth&0xf) << 5);
657
+ *dosdate |= (WORD)((st.wDay&0x1f));
658
+ *dostime = (WORD)((st.wHour&0x1f) << 11);
659
+ *dostime |= (WORD)((st.wMinute&0x3f) << 5);
660
+ *dostime |= (WORD)((st.wSecond*2)&0x1f);
661
+ }
662
+
663
+ lutime_t filetime2timet(const FILETIME ft)
664
+ { LONGLONG i = *(LONGLONG*)&ft;
665
+ return (lutime_t)((i-116444736000000000LL)/10000000LL);
666
+ }
667
+
668
+ void GetNow(lutime_t *pft, WORD *dosdate, WORD *dostime)
669
+ { SYSTEMTIME st; GetLocalTime(&st);
670
+ FILETIME ft; SystemTimeToFileTime(&st,&ft);
671
+ filetime2dosdatetime(ft,dosdate,dostime);
672
+ *pft = filetime2timet(ft);
673
+ }
674
+
675
+ DWORD GetFilePosZ(HANDLE hfout)
676
+ { return SetFilePointer(hfout,0,0,FILE_CURRENT);
677
+ }
678
+
679
+
680
+ ZRESULT GetFileInfo(HANDLE hf, ulg *attr, long *size, iztimes *times, ulg *timestamp)
681
+ { // The handle must be a handle to a file
682
+ // The date and time is returned in a long with the date most significant to allow
683
+ // unsigned integer comparison of absolute times. The attributes have two
684
+ // high bytes unix attr, and two low bytes a mapping of that to DOS attr.
685
+ //struct stat s; int res=stat(fn,&s); if (res!=0) return false;
686
+ // translate windows file attributes into zip ones.
687
+ BY_HANDLE_FILE_INFORMATION bhi; BOOL res=GetFileInformationByHandle(hf,&bhi);
688
+ if (!res) return ZR_NOFILE;
689
+ DWORD fa=bhi.dwFileAttributes; ulg a=0;
690
+ // Zip uses the lower word for its interpretation of windows stuff
691
+ if (fa&FILE_ATTRIBUTE_READONLY) a|=0x01;
692
+ if (fa&FILE_ATTRIBUTE_HIDDEN) a|=0x02;
693
+ if (fa&FILE_ATTRIBUTE_SYSTEM) a|=0x04;
694
+ if (fa&FILE_ATTRIBUTE_DIRECTORY)a|=0x10;
695
+ if (fa&FILE_ATTRIBUTE_ARCHIVE) a|=0x20;
696
+ // It uses the upper word for standard unix attr, which we manually construct
697
+ if (fa&FILE_ATTRIBUTE_DIRECTORY)a|=0x40000000; // directory
698
+ else a|=0x80000000; // normal file
699
+ a|=0x01000000; // readable
700
+ if (fa&FILE_ATTRIBUTE_READONLY) {} else a|=0x00800000; // writeable
701
+ // now just a small heuristic to check if it's an executable:
702
+ DWORD red, hsize=GetFileSize(hf,NULL); if (hsize>40)
703
+ { SetFilePointer(hf,0,NULL,FILE_BEGIN); unsigned short magic; ReadFile(hf,&magic,sizeof(magic),&red,NULL);
704
+ SetFilePointer(hf,36,NULL,FILE_BEGIN); unsigned long hpos; ReadFile(hf,&hpos,sizeof(hpos),&red,NULL);
705
+ if (magic==0x54AD && hsize>hpos+4+20+28)
706
+ { SetFilePointer(hf,hpos,NULL,FILE_BEGIN); unsigned long signature; ReadFile(hf,&signature,sizeof(signature),&red,NULL);
707
+ if (signature==IMAGE_DOS_SIGNATURE || signature==IMAGE_OS2_SIGNATURE
708
+ || signature==IMAGE_OS2_SIGNATURE_LE || signature==IMAGE_NT_SIGNATURE)
709
+ { a |= 0x00400000; // executable
710
+ }
711
+ }
712
+ }
713
+ //
714
+ if (attr!=NULL) *attr = a;
715
+ if (size!=NULL) *size = hsize;
716
+ if (times!=NULL)
717
+ { // lutime_t is 32bit number of seconds elapsed since 0:0:0GMT, Jan1, 1970.
718
+ // but FILETIME is 64bit number of 100-nanosecs since Jan1, 1601
719
+ times->atime = filetime2timet(bhi.ftLastAccessTime);
720
+ times->mtime = filetime2timet(bhi.ftLastWriteTime);
721
+ times->ctime = filetime2timet(bhi.ftCreationTime);
722
+ }
723
+ if (timestamp!=NULL)
724
+ { WORD dosdate,dostime;
725
+ filetime2dosdatetime(bhi.ftLastWriteTime,&dosdate,&dostime);
726
+ *timestamp = (WORD)dostime | (((DWORD)dosdate)<<16);
727
+ }
728
+ return ZR_OK;
729
+ }
730
+ #endif
731
+ // ----------------------------------------------------------------------
732
+
733
+
734
+
735
+
736
+
737
+ void Assert(TState &state,bool cond, const char *msg)
738
+ { if (cond) return;
739
+ state.err=msg;
740
+ }
741
+ void Trace(const char *x, ...) {va_list paramList; va_start(paramList, x); paramList; va_end(paramList);}
742
+ void Tracec(bool ,const char *x, ...) {va_list paramList; va_start(paramList, x); paramList; va_end(paramList);}
743
+
744
+
745
+
746
+ // ===========================================================================
747
+ // Local (static) routines in this file.
748
+ //
749
+
750
+ void init_block (TState &);
751
+ void pqdownheap (TState &,ct_data *tree, int k);
752
+ void gen_bitlen (TState &,tree_desc *desc);
753
+ void gen_codes (TState &state,ct_data *tree, int max_code);
754
+ void build_tree (TState &,tree_desc *desc);
755
+ void scan_tree (TState &,ct_data *tree, int max_code);
756
+ void send_tree (TState &state,ct_data *tree, int max_code);
757
+ int build_bl_tree (TState &);
758
+ void send_all_trees (TState &state,int lcodes, int dcodes, int blcodes);
759
+ void compress_block (TState &state,ct_data *ltree, ct_data *dtree);
760
+ void set_file_type (TState &);
761
+ void send_bits (TState &state, int value, int length);
762
+ unsigned bi_reverse (unsigned code, int len);
763
+ void bi_windup (TState &state);
764
+ void copy_block (TState &state,char *buf, unsigned len, int header);
765
+
766
+
767
+ #define send_code(state, c, tree) send_bits(state, tree[c].fc.code, tree[c].dl.len)
768
+ // Send a code of the given tree. c and tree must not have side effects
769
+
770
+ // alternatively...
771
+ //#define send_code(state, c, tree)
772
+ // { if (state.verbose>1) fprintf(stderr,"\ncd %3d ",(c));
773
+ // send_bits(state, tree[c].fc.code, tree[c].dl.len); }
774
+
775
+ #define d_code(dist) ((dist) < 256 ? state.ts.dist_code[dist] : state.ts.dist_code[256+((dist)>>7)])
776
+ // Mapping from a distance to a distance code. dist is the distance - 1 and
777
+ // must not have side effects. dist_code[256] and dist_code[257] are never used.
778
+
779
+ #define Max(a,b) (a >= b ? a : b)
780
+ /* the arguments must not have side effects */
781
+
782
+ /* ===========================================================================
783
+ * Allocate the match buffer, initialize the various tables and save the
784
+ * location of the internal file attribute (ascii/binary) and method
785
+ * (DEFLATE/STORE).
786
+ */
787
+ void ct_init(TState &state, ush *attr)
788
+ {
789
+ int n; /* iterates over tree elements */
790
+ int bits; /* bit counter */
791
+ int length; /* length value */
792
+ int code; /* code value */
793
+ int dist; /* distance index */
794
+
795
+ state.ts.file_type = attr;
796
+ //state.ts.file_method = method;
797
+ state.ts.cmpr_bytelen = state.ts.cmpr_len_bits = 0L;
798
+ state.ts.input_len = 0L;
799
+
800
+ if (state.ts.static_dtree[0].dl.len != 0) return; /* ct_init already called */
801
+
802
+ /* Initialize the mapping length (0..255) -> length code (0..28) */
803
+ length = 0;
804
+ for (code = 0; code < LENGTH_CODES-1; code++) {
805
+ state.ts.base_length[code] = length;
806
+ for (n = 0; n < (1<<extra_lbits[code]); n++) {
807
+ state.ts.length_code[length++] = (uch)code;
808
+ }
809
+ }
810
+ Assert(state,length == 256, "ct_init: length != 256");
811
+ /* Note that the length 255 (match length 258) can be represented
812
+ * in two different ways: code 284 + 5 bits or code 285, so we
813
+ * overwrite length_code[255] to use the best encoding:
814
+ */
815
+ state.ts.length_code[length-1] = (uch)code;
816
+
817
+ /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
818
+ dist = 0;
819
+ for (code = 0 ; code < 16; code++) {
820
+ state.ts.base_dist[code] = dist;
821
+ for (n = 0; n < (1<<extra_dbits[code]); n++) {
822
+ state.ts.dist_code[dist++] = (uch)code;
823
+ }
824
+ }
825
+ Assert(state,dist == 256, "ct_init: dist != 256");
826
+ dist >>= 7; /* from now on, all distances are divided by 128 */
827
+ for ( ; code < D_CODES; code++) {
828
+ state.ts.base_dist[code] = dist << 7;
829
+ for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
830
+ state.ts.dist_code[256 + dist++] = (uch)code;
831
+ }
832
+ }
833
+ Assert(state,dist == 256, "ct_init: 256+dist != 512");
834
+
835
+ /* Construct the codes of the static literal tree */
836
+ for (bits = 0; bits <= MAX_BITS; bits++) state.ts.bl_count[bits] = 0;
837
+ n = 0;
838
+ while (n <= 143) state.ts.static_ltree[n++].dl.len = 8, state.ts.bl_count[8]++;
839
+ while (n <= 255) state.ts.static_ltree[n++].dl.len = 9, state.ts.bl_count[9]++;
840
+ while (n <= 279) state.ts.static_ltree[n++].dl.len = 7, state.ts.bl_count[7]++;
841
+ while (n <= 287) state.ts.static_ltree[n++].dl.len = 8, state.ts.bl_count[8]++;
842
+ /* fc.codes 286 and 287 do not exist, but we must include them in the
843
+ * tree construction to get a canonical Huffman tree (longest code
844
+ * all ones)
845
+ */
846
+ gen_codes(state,(ct_data *)state.ts.static_ltree, L_CODES+1);
847
+
848
+ /* The static distance tree is trivial: */
849
+ for (n = 0; n < D_CODES; n++) {
850
+ state.ts.static_dtree[n].dl.len = 5;
851
+ state.ts.static_dtree[n].fc.code = (ush)bi_reverse(n, 5);
852
+ }
853
+
854
+ /* Initialize the first block of the first file: */
855
+ init_block(state);
856
+ }
857
+
858
+ /* ===========================================================================
859
+ * Initialize a new block.
860
+ */
861
+ void init_block(TState &state)
862
+ {
863
+ int n; /* iterates over tree elements */
864
+
865
+ /* Initialize the trees. */
866
+ for (n = 0; n < L_CODES; n++) state.ts.dyn_ltree[n].fc.freq = 0;
867
+ for (n = 0; n < D_CODES; n++) state.ts.dyn_dtree[n].fc.freq = 0;
868
+ for (n = 0; n < BL_CODES; n++) state.ts.bl_tree[n].fc.freq = 0;
869
+
870
+ state.ts.dyn_ltree[END_BLOCK].fc.freq = 1;
871
+ state.ts.opt_len = state.ts.static_len = 0L;
872
+ state.ts.last_lit = state.ts.last_dist = state.ts.last_flags = 0;
873
+ state.ts.flags = 0; state.ts.flag_bit = 1;
874
+ }
875
+
876
+ #define SMALLEST 1
877
+ /* Index within the heap array of least frequent node in the Huffman tree */
878
+
879
+
880
+ /* ===========================================================================
881
+ * Remove the smallest element from the heap and recreate the heap with
882
+ * one less element. Updates heap and heap_len.
883
+ */
884
+ #define pqremove(tree, top) \
885
+ {\
886
+ top = state.ts.heap[SMALLEST]; \
887
+ state.ts.heap[SMALLEST] = state.ts.heap[state.ts.heap_len--]; \
888
+ pqdownheap(state,tree, SMALLEST); \
889
+ }
890
+
891
+ /* ===========================================================================
892
+ * Compares to subtrees, using the tree depth as tie breaker when
893
+ * the subtrees have equal frequency. This minimizes the worst case length.
894
+ */
895
+ #define smaller(tree, n, m) \
896
+ (tree[n].fc.freq < tree[m].fc.freq || \
897
+ (tree[n].fc.freq == tree[m].fc.freq && state.ts.depth[n] <= state.ts.depth[m]))
898
+
899
+ /* ===========================================================================
900
+ * Restore the heap property by moving down the tree starting at node k,
901
+ * exchanging a node with the smallest of its two sons if necessary, stopping
902
+ * when the heap property is re-established (each father smaller than its
903
+ * two sons).
904
+ */
905
+ void pqdownheap(TState &state,ct_data *tree, int k)
906
+ {
907
+ int v = state.ts.heap[k];
908
+ int j = k << 1; /* left son of k */
909
+ int htemp; /* required because of bug in SASC compiler */
910
+
911
+ while (j <= state.ts.heap_len) {
912
+ /* Set j to the smallest of the two sons: */
913
+ if (j < state.ts.heap_len && smaller(tree, state.ts.heap[j+1], state.ts.heap[j])) j++;
914
+
915
+ /* Exit if v is smaller than both sons */
916
+ htemp = state.ts.heap[j];
917
+ if (smaller(tree, v, htemp)) break;
918
+
919
+ /* Exchange v with the smallest son */
920
+ state.ts.heap[k] = htemp;
921
+ k = j;
922
+
923
+ /* And continue down the tree, setting j to the left son of k */
924
+ j <<= 1;
925
+ }
926
+ state.ts.heap[k] = v;
927
+ }
928
+
929
+ /* ===========================================================================
930
+ * Compute the optimal bit lengths for a tree and update the total bit length
931
+ * for the current block.
932
+ * IN assertion: the fields freq and dad are set, heap[heap_max] and
933
+ * above are the tree nodes sorted by increasing frequency.
934
+ * OUT assertions: the field len is set to the optimal bit length, the
935
+ * array bl_count contains the frequencies for each bit length.
936
+ * The length opt_len is updated; static_len is also updated if stree is
937
+ * not null.
938
+ */
939
+ void gen_bitlen(TState &state,tree_desc *desc)
940
+ {
941
+ ct_data *tree = desc->dyn_tree;
942
+ const int *extra = desc->extra_bits;
943
+ int base = desc->extra_base;
944
+ int max_code = desc->max_code;
945
+ int max_length = desc->max_length;
946
+ ct_data *stree = desc->static_tree;
947
+ int h; /* heap index */
948
+ int n, m; /* iterate over the tree elements */
949
+ int bits; /* bit length */
950
+ int xbits; /* extra bits */
951
+ ush f; /* frequency */
952
+ int overflow = 0; /* number of elements with bit length too large */
953
+
954
+ for (bits = 0; bits <= MAX_BITS; bits++) state.ts.bl_count[bits] = 0;
955
+
956
+ /* In a first pass, compute the optimal bit lengths (which may
957
+ * overflow in the case of the bit length tree).
958
+ */
959
+ tree[state.ts.heap[state.ts.heap_max]].dl.len = 0; /* root of the heap */
960
+
961
+ for (h = state.ts.heap_max+1; h < HEAP_SIZE; h++) {
962
+ n = state.ts.heap[h];
963
+ bits = tree[tree[n].dl.dad].dl.len + 1;
964
+ if (bits > max_length) bits = max_length, overflow++;
965
+ tree[n].dl.len = (ush)bits;
966
+ /* We overwrite tree[n].dl.dad which is no longer needed */
967
+
968
+ if (n > max_code) continue; /* not a leaf node */
969
+
970
+ state.ts.bl_count[bits]++;
971
+ xbits = 0;
972
+ if (n >= base) xbits = extra[n-base];
973
+ f = tree[n].fc.freq;
974
+ state.ts.opt_len += (ulg)f * (bits + xbits);
975
+ if (stree) state.ts.static_len += (ulg)f * (stree[n].dl.len + xbits);
976
+ }
977
+ if (overflow == 0) return;
978
+
979
+ Trace("\nbit length overflow\n");
980
+ /* This happens for example on obj2 and pic of the Calgary corpus */
981
+
982
+ /* Find the first bit length which could increase: */
983
+ do {
984
+ bits = max_length-1;
985
+ while (state.ts.bl_count[bits] == 0) bits--;
986
+ state.ts.bl_count[bits]--; /* move one leaf down the tree */
987
+ state.ts.bl_count[bits+1] += (ush)2; /* move one overflow item as its brother */
988
+ state.ts.bl_count[max_length]--;
989
+ /* The brother of the overflow item also moves one step up,
990
+ * but this does not affect bl_count[max_length]
991
+ */
992
+ overflow -= 2;
993
+ } while (overflow > 0);
994
+
995
+ /* Now recompute all bit lengths, scanning in increasing frequency.
996
+ * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
997
+ * lengths instead of fixing only the wrong ones. This idea is taken
998
+ * from 'ar' written by Haruhiko Okumura.)
999
+ */
1000
+ for (bits = max_length; bits != 0; bits--) {
1001
+ n = state.ts.bl_count[bits];
1002
+ while (n != 0) {
1003
+ m = state.ts.heap[--h];
1004
+ if (m > max_code) continue;
1005
+ if (tree[m].dl.len != (ush)bits) {
1006
+ Trace("code %d bits %d->%d\n", m, tree[m].dl.len, bits);
1007
+ state.ts.opt_len += ((long)bits-(long)tree[m].dl.len)*(long)tree[m].fc.freq;
1008
+ tree[m].dl.len = (ush)bits;
1009
+ }
1010
+ n--;
1011
+ }
1012
+ }
1013
+ }
1014
+
1015
+ /* ===========================================================================
1016
+ * Generate the codes for a given tree and bit counts (which need not be
1017
+ * optimal).
1018
+ * IN assertion: the array bl_count contains the bit length statistics for
1019
+ * the given tree and the field len is set for all tree elements.
1020
+ * OUT assertion: the field code is set for all tree elements of non
1021
+ * zero code length.
1022
+ */
1023
+ void gen_codes (TState &state, ct_data *tree, int max_code)
1024
+ {
1025
+ ush next_code[MAX_BITS+1]; /* next code value for each bit length */
1026
+ ush code = 0; /* running code value */
1027
+ int bits; /* bit index */
1028
+ int n; /* code index */
1029
+
1030
+ /* The distribution counts are first used to generate the code values
1031
+ * without bit reversal.
1032
+ */
1033
+ for (bits = 1; bits <= MAX_BITS; bits++) {
1034
+ next_code[bits] = code = (ush)((code + state.ts.bl_count[bits-1]) << 1);
1035
+ }
1036
+ /* Check that the bit counts in bl_count are consistent. The last code
1037
+ * must be all ones.
1038
+ */
1039
+ Assert(state,code + state.ts.bl_count[MAX_BITS]-1 == (1<< ((ush) MAX_BITS)) - 1,
1040
+ "inconsistent bit counts");
1041
+ Trace("\ngen_codes: max_code %d ", max_code);
1042
+
1043
+ for (n = 0; n <= max_code; n++) {
1044
+ int len = tree[n].dl.len;
1045
+ if (len == 0) continue;
1046
+ /* Now reverse the bits */
1047
+ tree[n].fc.code = (ush)bi_reverse(next_code[len]++, len);
1048
+
1049
+ //Tracec(tree != state.ts.static_ltree, "\nn %3d %c l %2d c %4x (%x) ", n, (isgraph(n) ? n : ' '), len, tree[n].fc.code, next_code[len]-1);
1050
+ }
1051
+ }
1052
+
1053
+ /* ===========================================================================
1054
+ * Construct one Huffman tree and assigns the code bit strings and lengths.
1055
+ * Update the total bit length for the current block.
1056
+ * IN assertion: the field freq is set for all tree elements.
1057
+ * OUT assertions: the fields len and code are set to the optimal bit length
1058
+ * and corresponding code. The length opt_len is updated; static_len is
1059
+ * also updated if stree is not null. The field max_code is set.
1060
+ */
1061
+ void build_tree(TState &state,tree_desc *desc)
1062
+ {
1063
+ ct_data *tree = desc->dyn_tree;
1064
+ ct_data *stree = desc->static_tree;
1065
+ int elems = desc->elems;
1066
+ int n, m; /* iterate over heap elements */
1067
+ int max_code = -1; /* largest code with non zero frequency */
1068
+ int node = elems; /* next internal node of the tree */
1069
+
1070
+ /* Construct the initial heap, with least frequent element in
1071
+ * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
1072
+ * heap[0] is not used.
1073
+ */
1074
+ state.ts.heap_len = 0, state.ts.heap_max = HEAP_SIZE;
1075
+
1076
+ for (n = 0; n < elems; n++) {
1077
+ if (tree[n].fc.freq != 0) {
1078
+ state.ts.heap[++state.ts.heap_len] = max_code = n;
1079
+ state.ts.depth[n] = 0;
1080
+ } else {
1081
+ tree[n].dl.len = 0;
1082
+ }
1083
+ }
1084
+
1085
+ /* The pkzip format requires that at least one distance code exists,
1086
+ * and that at least one bit should be sent even if there is only one
1087
+ * possible code. So to avoid special checks later on we force at least
1088
+ * two codes of non zero frequency.
1089
+ */
1090
+ while (state.ts.heap_len < 2) {
1091
+ int newcp = state.ts.heap[++state.ts.heap_len] = (max_code < 2 ? ++max_code : 0);
1092
+ tree[newcp].fc.freq = 1;
1093
+ state.ts.depth[newcp] = 0;
1094
+ state.ts.opt_len--; if (stree) state.ts.static_len -= stree[newcp].dl.len;
1095
+ /* new is 0 or 1 so it does not have extra bits */
1096
+ }
1097
+ desc->max_code = max_code;
1098
+
1099
+ /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
1100
+ * establish sub-heaps of increasing lengths:
1101
+ */
1102
+ for (n = state.ts.heap_len/2; n >= 1; n--) pqdownheap(state,tree, n);
1103
+
1104
+ /* Construct the Huffman tree by repeatedly combining the least two
1105
+ * frequent nodes.
1106
+ */
1107
+ do {
1108
+ pqremove(tree, n); /* n = node of least frequency */
1109
+ m = state.ts.heap[SMALLEST]; /* m = node of next least frequency */
1110
+
1111
+ state.ts.heap[--state.ts.heap_max] = n; /* keep the nodes sorted by frequency */
1112
+ state.ts.heap[--state.ts.heap_max] = m;
1113
+
1114
+ /* Create a new node father of n and m */
1115
+ tree[node].fc.freq = (ush)(tree[n].fc.freq + tree[m].fc.freq);
1116
+ state.ts.depth[node] = (uch) (Max(state.ts.depth[n], state.ts.depth[m]) + 1);
1117
+ tree[n].dl.dad = tree[m].dl.dad = (ush)node;
1118
+ /* and insert the new node in the heap */
1119
+ state.ts.heap[SMALLEST] = node++;
1120
+ pqdownheap(state,tree, SMALLEST);
1121
+
1122
+ } while (state.ts.heap_len >= 2);
1123
+
1124
+ state.ts.heap[--state.ts.heap_max] = state.ts.heap[SMALLEST];
1125
+
1126
+ /* At this point, the fields freq and dad are set. We can now
1127
+ * generate the bit lengths.
1128
+ */
1129
+ gen_bitlen(state,(tree_desc *)desc);
1130
+
1131
+ /* The field len is now set, we can generate the bit codes */
1132
+ gen_codes (state,(ct_data *)tree, max_code);
1133
+ }
1134
+
1135
+ /* ===========================================================================
1136
+ * Scan a literal or distance tree to determine the frequencies of the codes
1137
+ * in the bit length tree. Updates opt_len to take into account the repeat
1138
+ * counts. (The contribution of the bit length codes will be added later
1139
+ * during the construction of bl_tree.)
1140
+ */
1141
+ void scan_tree (TState &state,ct_data *tree, int max_code)
1142
+ {
1143
+ int n; /* iterates over all tree elements */
1144
+ int prevlen = -1; /* last emitted length */
1145
+ int curlen; /* length of current code */
1146
+ int nextlen = tree[0].dl.len; /* length of next code */
1147
+ int count = 0; /* repeat count of the current code */
1148
+ int max_count = 7; /* max repeat count */
1149
+ int min_count = 4; /* min repeat count */
1150
+
1151
+ if (nextlen == 0) max_count = 138, min_count = 3;
1152
+ tree[max_code+1].dl.len = (ush)-1; /* guard */
1153
+
1154
+ for (n = 0; n <= max_code; n++) {
1155
+ curlen = nextlen; nextlen = tree[n+1].dl.len;
1156
+ if (++count < max_count && curlen == nextlen) {
1157
+ continue;
1158
+ } else if (count < min_count) {
1159
+ state.ts.bl_tree[curlen].fc.freq = (ush)(state.ts.bl_tree[curlen].fc.freq + count);
1160
+ } else if (curlen != 0) {
1161
+ if (curlen != prevlen) state.ts.bl_tree[curlen].fc.freq++;
1162
+ state.ts.bl_tree[REP_3_6].fc.freq++;
1163
+ } else if (count <= 10) {
1164
+ state.ts.bl_tree[REPZ_3_10].fc.freq++;
1165
+ } else {
1166
+ state.ts.bl_tree[REPZ_11_138].fc.freq++;
1167
+ }
1168
+ count = 0; prevlen = curlen;
1169
+ if (nextlen == 0) {
1170
+ max_count = 138, min_count = 3;
1171
+ } else if (curlen == nextlen) {
1172
+ max_count = 6, min_count = 3;
1173
+ } else {
1174
+ max_count = 7, min_count = 4;
1175
+ }
1176
+ }
1177
+ }
1178
+
1179
+ /* ===========================================================================
1180
+ * Send a literal or distance tree in compressed form, using the codes in
1181
+ * bl_tree.
1182
+ */
1183
+ void send_tree (TState &state, ct_data *tree, int max_code)
1184
+ {
1185
+ int n; /* iterates over all tree elements */
1186
+ int prevlen = -1; /* last emitted length */
1187
+ int curlen; /* length of current code */
1188
+ int nextlen = tree[0].dl.len; /* length of next code */
1189
+ int count = 0; /* repeat count of the current code */
1190
+ int max_count = 7; /* max repeat count */
1191
+ int min_count = 4; /* min repeat count */
1192
+
1193
+ /* tree[max_code+1].dl.len = -1; */ /* guard already set */
1194
+ if (nextlen == 0) max_count = 138, min_count = 3;
1195
+
1196
+ for (n = 0; n <= max_code; n++) {
1197
+ curlen = nextlen; nextlen = tree[n+1].dl.len;
1198
+ if (++count < max_count && curlen == nextlen) {
1199
+ continue;
1200
+ } else if (count < min_count) {
1201
+ do { send_code(state, curlen, state.ts.bl_tree); } while (--count != 0);
1202
+
1203
+ } else if (curlen != 0) {
1204
+ if (curlen != prevlen) {
1205
+ send_code(state, curlen, state.ts.bl_tree); count--;
1206
+ }
1207
+ Assert(state,count >= 3 && count <= 6, " 3_6?");
1208
+ send_code(state,REP_3_6, state.ts.bl_tree); send_bits(state,count-3, 2);
1209
+
1210
+ } else if (count <= 10) {
1211
+ send_code(state,REPZ_3_10, state.ts.bl_tree); send_bits(state,count-3, 3);
1212
+
1213
+ } else {
1214
+ send_code(state,REPZ_11_138, state.ts.bl_tree); send_bits(state,count-11, 7);
1215
+ }
1216
+ count = 0; prevlen = curlen;
1217
+ if (nextlen == 0) {
1218
+ max_count = 138, min_count = 3;
1219
+ } else if (curlen == nextlen) {
1220
+ max_count = 6, min_count = 3;
1221
+ } else {
1222
+ max_count = 7, min_count = 4;
1223
+ }
1224
+ }
1225
+ }
1226
+
1227
+ /* ===========================================================================
1228
+ * Construct the Huffman tree for the bit lengths and return the index in
1229
+ * bl_order of the last bit length code to send.
1230
+ */
1231
+ int build_bl_tree(TState &state)
1232
+ {
1233
+ int max_blindex; /* index of last bit length code of non zero freq */
1234
+
1235
+ /* Determine the bit length frequencies for literal and distance trees */
1236
+ scan_tree(state,(ct_data *)state.ts.dyn_ltree, state.ts.l_desc.max_code);
1237
+ scan_tree(state,(ct_data *)state.ts.dyn_dtree, state.ts.d_desc.max_code);
1238
+
1239
+ /* Build the bit length tree: */
1240
+ build_tree(state,(tree_desc *)(&state.ts.bl_desc));
1241
+ /* opt_len now includes the length of the tree representations, except
1242
+ * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.
1243
+ */
1244
+
1245
+ /* Determine the number of bit length codes to send. The pkzip format
1246
+ * requires that at least 4 bit length codes be sent. (appnote.txt says
1247
+ * 3 but the actual value used is 4.)
1248
+ */
1249
+ for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
1250
+ if (state.ts.bl_tree[bl_order[max_blindex]].dl.len != 0) break;
1251
+ }
1252
+ /* Update opt_len to include the bit length tree and counts */
1253
+ state.ts.opt_len += 3*(max_blindex+1) + 5+5+4;
1254
+ Trace("\ndyn trees: dyn %ld, stat %ld", state.ts.opt_len, state.ts.static_len);
1255
+
1256
+ return max_blindex;
1257
+ }
1258
+
1259
+ /* ===========================================================================
1260
+ * Send the header for a block using dynamic Huffman trees: the counts, the
1261
+ * lengths of the bit length codes, the literal tree and the distance tree.
1262
+ * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
1263
+ */
1264
+ void send_all_trees(TState &state,int lcodes, int dcodes, int blcodes)
1265
+ {
1266
+ int rank; /* index in bl_order */
1267
+
1268
+ Assert(state,lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
1269
+ Assert(state,lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
1270
+ "too many codes");
1271
+ Trace("\nbl counts: ");
1272
+ send_bits(state,lcodes-257, 5);
1273
+ /* not +255 as stated in appnote.txt 1.93a or -256 in 2.04c */
1274
+ send_bits(state,dcodes-1, 5);
1275
+ send_bits(state,blcodes-4, 4); /* not -3 as stated in appnote.txt */
1276
+ for (rank = 0; rank < blcodes; rank++) {
1277
+ Trace("\nbl code %2d ", bl_order[rank]);
1278
+ send_bits(state,state.ts.bl_tree[bl_order[rank]].dl.len, 3);
1279
+ }
1280
+ Trace("\nbl tree: sent %ld", state.bs.bits_sent);
1281
+
1282
+ send_tree(state,(ct_data *)state.ts.dyn_ltree, lcodes-1); /* send the literal tree */
1283
+ Trace("\nlit tree: sent %ld", state.bs.bits_sent);
1284
+
1285
+ send_tree(state,(ct_data *)state.ts.dyn_dtree, dcodes-1); /* send the distance tree */
1286
+ Trace("\ndist tree: sent %ld", state.bs.bits_sent);
1287
+ }
1288
+
1289
+ /* ===========================================================================
1290
+ * Determine the best encoding for the current block: dynamic trees, static
1291
+ * trees or store, and output the encoded block to the zip file. This function
1292
+ * returns the total compressed length (in bytes) for the file so far.
1293
+ */
1294
+ ulg flush_block(TState &state,char *buf, ulg stored_len, int eof)
1295
+ {
1296
+ ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
1297
+ int max_blindex; /* index of last bit length code of non zero freq */
1298
+
1299
+ state.ts.flag_buf[state.ts.last_flags] = state.ts.flags; /* Save the flags for the last 8 items */
1300
+
1301
+ /* Check if the file is ascii or binary */
1302
+ if (*state.ts.file_type == (ush)UNKNOWN) set_file_type(state);
1303
+
1304
+ /* Construct the literal and distance trees */
1305
+ build_tree(state,(tree_desc *)(&state.ts.l_desc));
1306
+ Trace("\nlit data: dyn %ld, stat %ld", state.ts.opt_len, state.ts.static_len);
1307
+
1308
+ build_tree(state,(tree_desc *)(&state.ts.d_desc));
1309
+ Trace("\ndist data: dyn %ld, stat %ld", state.ts.opt_len, state.ts.static_len);
1310
+ /* At this point, opt_len and static_len are the total bit lengths of
1311
+ * the compressed block data, excluding the tree representations.
1312
+ */
1313
+
1314
+ /* Build the bit length tree for the above two trees, and get the index
1315
+ * in bl_order of the last bit length code to send.
1316
+ */
1317
+ max_blindex = build_bl_tree(state);
1318
+
1319
+ /* Determine the best encoding. Compute first the block length in bytes */
1320
+ opt_lenb = (state.ts.opt_len+3+7)>>3;
1321
+ static_lenb = (state.ts.static_len+3+7)>>3;
1322
+ state.ts.input_len += stored_len; /* for debugging only */
1323
+
1324
+ Trace("\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u dist %u ",
1325
+ opt_lenb, state.ts.opt_len, static_lenb, state.ts.static_len, stored_len,
1326
+ state.ts.last_lit, state.ts.last_dist);
1327
+
1328
+ if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
1329
+
1330
+ // Originally, zip allowed the file to be transformed from a compressed
1331
+ // into a stored file in the case where compression failed, there
1332
+ // was only one block, and it was allowed to change. I've removed this
1333
+ // possibility since the code's cleaner if no changes are allowed.
1334
+ //if (stored_len <= opt_lenb && eof && state.ts.cmpr_bytelen == 0L
1335
+ // && state.ts.cmpr_len_bits == 0L && state.seekable)
1336
+ //{ // && state.ts.file_method != NULL
1337
+ // // Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there:
1338
+ // Assert(state,buf!=NULL,"block vanished");
1339
+ // copy_block(state,buf, (unsigned)stored_len, 0); // without header
1340
+ // state.ts.cmpr_bytelen = stored_len;
1341
+ // Assert(state,false,"unimplemented *state.ts.file_method = STORE;");
1342
+ // //*state.ts.file_method = STORE;
1343
+ //}
1344
+ //else
1345
+ if (stored_len+4 <= opt_lenb && buf != (char*)NULL) {
1346
+ /* 4: two words for the lengths */
1347
+ /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.
1348
+ * Otherwise we can't have processed more than WSIZE input bytes since
1349
+ * the last block flush, because compression would have been
1350
+ * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
1351
+ * transform a block into a stored block.
1352
+ */
1353
+ send_bits(state,(STORED_BLOCK<<1)+eof, 3); /* send block type */
1354
+ state.ts.cmpr_bytelen += ((state.ts.cmpr_len_bits + 3 + 7) >> 3) + stored_len + 4;
1355
+ state.ts.cmpr_len_bits = 0L;
1356
+
1357
+ copy_block(state,buf, (unsigned)stored_len, 1); /* with header */
1358
+ }
1359
+ else if (static_lenb == opt_lenb) {
1360
+ send_bits(state,(STATIC_TREES<<1)+eof, 3);
1361
+ compress_block(state,(ct_data *)state.ts.static_ltree, (ct_data *)state.ts.static_dtree);
1362
+ state.ts.cmpr_len_bits += 3 + state.ts.static_len;
1363
+ state.ts.cmpr_bytelen += state.ts.cmpr_len_bits >> 3;
1364
+ state.ts.cmpr_len_bits &= 7L;
1365
+ }
1366
+ else {
1367
+ send_bits(state,(DYN_TREES<<1)+eof, 3);
1368
+ send_all_trees(state,state.ts.l_desc.max_code+1, state.ts.d_desc.max_code+1, max_blindex+1);
1369
+ compress_block(state,(ct_data *)state.ts.dyn_ltree, (ct_data *)state.ts.dyn_dtree);
1370
+ state.ts.cmpr_len_bits += 3 + state.ts.opt_len;
1371
+ state.ts.cmpr_bytelen += state.ts.cmpr_len_bits >> 3;
1372
+ state.ts.cmpr_len_bits &= 7L;
1373
+ }
1374
+ Assert(state,((state.ts.cmpr_bytelen << 3) + state.ts.cmpr_len_bits) == state.bs.bits_sent, "bad compressed size");
1375
+ init_block(state);
1376
+
1377
+ if (eof) {
1378
+ // Assert(state,input_len == isize, "bad input size");
1379
+ bi_windup(state);
1380
+ state.ts.cmpr_len_bits += 7; /* align on byte boundary */
1381
+ }
1382
+ Trace("\n");
1383
+
1384
+ return state.ts.cmpr_bytelen + (state.ts.cmpr_len_bits >> 3);
1385
+ }
1386
+
1387
+ /* ===========================================================================
1388
+ * Save the match info and tally the frequency counts. Return true if
1389
+ * the current block must be flushed.
1390
+ */
1391
+ int ct_tally (TState &state,int dist, int lc)
1392
+ {
1393
+ state.ts.l_buf[state.ts.last_lit++] = (uch)lc;
1394
+ if (dist == 0) {
1395
+ /* lc is the unmatched char */
1396
+ state.ts.dyn_ltree[lc].fc.freq++;
1397
+ } else {
1398
+ /* Here, lc is the match length - MIN_MATCH */
1399
+ dist--; /* dist = match distance - 1 */
1400
+ Assert(state,(ush)dist < (ush)MAX_DIST &&
1401
+ (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&
1402
+ (ush)d_code(dist) < (ush)D_CODES, "ct_tally: bad match");
1403
+
1404
+ state.ts.dyn_ltree[state.ts.length_code[lc]+LITERALS+1].fc.freq++;
1405
+ state.ts.dyn_dtree[d_code(dist)].fc.freq++;
1406
+
1407
+ state.ts.d_buf[state.ts.last_dist++] = (ush)dist;
1408
+ state.ts.flags |= state.ts.flag_bit;
1409
+ }
1410
+ state.ts.flag_bit <<= 1;
1411
+
1412
+ /* Output the flags if they fill a byte: */
1413
+ if ((state.ts.last_lit & 7) == 0) {
1414
+ state.ts.flag_buf[state.ts.last_flags++] = state.ts.flags;
1415
+ state.ts.flags = 0, state.ts.flag_bit = 1;
1416
+ }
1417
+ /* Try to guess if it is profitable to stop the current block here */
1418
+ if (state.level > 2 && (state.ts.last_lit & 0xfff) == 0) {
1419
+ /* Compute an upper bound for the compressed length */
1420
+ ulg out_length = (ulg)state.ts.last_lit*8L;
1421
+ ulg in_length = (ulg)state.ds.strstart-state.ds.block_start;
1422
+ int dcode;
1423
+ for (dcode = 0; dcode < D_CODES; dcode++) {
1424
+ out_length += (ulg)state.ts.dyn_dtree[dcode].fc.freq*(5L+extra_dbits[dcode]);
1425
+ }
1426
+ out_length >>= 3;
1427
+ Trace("\nlast_lit %u, last_dist %u, in %ld, out ~%ld(%ld%%) ",
1428
+ state.ts.last_lit, state.ts.last_dist, in_length, out_length,
1429
+ 100L - out_length*100L/in_length);
1430
+ if (state.ts.last_dist < state.ts.last_lit/2 && out_length < in_length/2) return 1;
1431
+ }
1432
+ return (state.ts.last_lit == LIT_BUFSIZE-1 || state.ts.last_dist == DIST_BUFSIZE);
1433
+ /* We avoid equality with LIT_BUFSIZE because of wraparound at 64K
1434
+ * on 16 bit machines and because stored blocks are restricted to
1435
+ * 64K-1 bytes.
1436
+ */
1437
+ }
1438
+
1439
+ /* ===========================================================================
1440
+ * Send the block data compressed using the given Huffman trees
1441
+ */
1442
+ void compress_block(TState &state,ct_data *ltree, ct_data *dtree)
1443
+ {
1444
+ unsigned dist; /* distance of matched string */
1445
+ int lc; /* match length or unmatched char (if dist == 0) */
1446
+ unsigned lx = 0; /* running index in l_buf */
1447
+ unsigned dx = 0; /* running index in d_buf */
1448
+ unsigned fx = 0; /* running index in flag_buf */
1449
+ uch flag = 0; /* current flags */
1450
+ unsigned code; /* the code to send */
1451
+ int extra; /* number of extra bits to send */
1452
+
1453
+ if (state.ts.last_lit != 0) do {
1454
+ if ((lx & 7) == 0) flag = state.ts.flag_buf[fx++];
1455
+ lc = state.ts.l_buf[lx++];
1456
+ if ((flag & 1) == 0) {
1457
+ send_code(state,lc, ltree); /* send a literal byte */
1458
+ } else {
1459
+ /* Here, lc is the match length - MIN_MATCH */
1460
+ code = state.ts.length_code[lc];
1461
+ send_code(state,code+LITERALS+1, ltree); /* send the length code */
1462
+ extra = extra_lbits[code];
1463
+ if (extra != 0) {
1464
+ lc -= state.ts.base_length[code];
1465
+ send_bits(state,lc, extra); /* send the extra length bits */
1466
+ }
1467
+ dist = state.ts.d_buf[dx++];
1468
+ /* Here, dist is the match distance - 1 */
1469
+ code = d_code(dist);
1470
+ Assert(state,code < D_CODES, "bad d_code");
1471
+
1472
+ send_code(state,code, dtree); /* send the distance code */
1473
+ extra = extra_dbits[code];
1474
+ if (extra != 0) {
1475
+ dist -= state.ts.base_dist[code];
1476
+ send_bits(state,dist, extra); /* send the extra distance bits */
1477
+ }
1478
+ } /* literal or match pair ? */
1479
+ flag >>= 1;
1480
+ } while (lx < state.ts.last_lit);
1481
+
1482
+ send_code(state,END_BLOCK, ltree);
1483
+ }
1484
+
1485
+ /* ===========================================================================
1486
+ * Set the file type to ASCII or BINARY, using a crude approximation:
1487
+ * binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise.
1488
+ * IN assertion: the fields freq of dyn_ltree are set and the total of all
1489
+ * frequencies does not exceed 64K (to fit in an int on 16 bit machines).
1490
+ */
1491
+ void set_file_type(TState &state)
1492
+ {
1493
+ int n = 0;
1494
+ unsigned ascii_freq = 0;
1495
+ unsigned bin_freq = 0;
1496
+ while (n < 7) bin_freq += state.ts.dyn_ltree[n++].fc.freq;
1497
+ while (n < 128) ascii_freq += state.ts.dyn_ltree[n++].fc.freq;
1498
+ while (n < LITERALS) bin_freq += state.ts.dyn_ltree[n++].fc.freq;
1499
+ *state.ts.file_type = (ush)(bin_freq > (ascii_freq >> 2) ? BINARY : ASCII);
1500
+ }
1501
+
1502
+
1503
+ /* ===========================================================================
1504
+ * Initialize the bit string routines.
1505
+ */
1506
+ void bi_init (TState &state,char *tgt_buf, unsigned tgt_size, int flsh_allowed)
1507
+ {
1508
+ state.bs.out_buf = tgt_buf;
1509
+ state.bs.out_size = tgt_size;
1510
+ state.bs.out_offset = 0;
1511
+ state.bs.flush_flg = flsh_allowed;
1512
+
1513
+ state.bs.bi_buf = 0;
1514
+ state.bs.bi_valid = 0;
1515
+ state.bs.bits_sent = 0L;
1516
+ }
1517
+
1518
+ /* ===========================================================================
1519
+ * Send a value on a given number of bits.
1520
+ * IN assertion: length <= 16 and value fits in length bits.
1521
+ */
1522
+ void send_bits(TState &state,int value, int length)
1523
+ {
1524
+ Assert(state,length > 0 && length <= 15, "invalid length");
1525
+ state.bs.bits_sent += (ulg)length;
1526
+ /* If not enough room in bi_buf, use (bi_valid) bits from bi_buf and
1527
+ * (Buf_size - bi_valid) bits from value to flush the filled bi_buf,
1528
+ * then fill in the rest of (value), leaving (length - (Buf_size-bi_valid))
1529
+ * unused bits in bi_buf.
1530
+ */
1531
+ state.bs.bi_buf |= (value << state.bs.bi_valid);
1532
+ state.bs.bi_valid += length;
1533
+ if (state.bs.bi_valid > (int)Buf_size) {
1534
+ PUTSHORT(state,state.bs.bi_buf);
1535
+ state.bs.bi_valid -= Buf_size;
1536
+ state.bs.bi_buf = (unsigned)value >> (length - state.bs.bi_valid);
1537
+ }
1538
+ }
1539
+
1540
+ /* ===========================================================================
1541
+ * Reverse the first len bits of a code, using straightforward code (a faster
1542
+ * method would use a table)
1543
+ * IN assertion: 1 <= len <= 15
1544
+ */
1545
+ unsigned bi_reverse(unsigned code, int len)
1546
+ {
1547
+ register unsigned res = 0;
1548
+ do {
1549
+ res |= code & 1;
1550
+ code >>= 1, res <<= 1;
1551
+ } while (--len > 0);
1552
+ return res >> 1;
1553
+ }
1554
+
1555
+ /* ===========================================================================
1556
+ * Write out any remaining bits in an incomplete byte.
1557
+ */
1558
+ void bi_windup(TState &state)
1559
+ {
1560
+ if (state.bs.bi_valid > 8) {
1561
+ PUTSHORT(state,state.bs.bi_buf);
1562
+ } else if (state.bs.bi_valid > 0) {
1563
+ PUTBYTE(state,state.bs.bi_buf);
1564
+ }
1565
+ if (state.bs.flush_flg) {
1566
+ state.flush_outbuf(state.param,state.bs.out_buf, &state.bs.out_offset);
1567
+ }
1568
+ state.bs.bi_buf = 0;
1569
+ state.bs.bi_valid = 0;
1570
+ state.bs.bits_sent = (state.bs.bits_sent+7) & ~7;
1571
+ }
1572
+
1573
+ /* ===========================================================================
1574
+ * Copy a stored block to the zip file, storing first the length and its
1575
+ * one's complement if requested.
1576
+ */
1577
+ void copy_block(TState &state, char *block, unsigned len, int header)
1578
+ {
1579
+ bi_windup(state); /* align on byte boundary */
1580
+
1581
+ if (header) {
1582
+ PUTSHORT(state,(ush)len);
1583
+ PUTSHORT(state,(ush)~len);
1584
+ state.bs.bits_sent += 2*16;
1585
+ }
1586
+ if (state.bs.flush_flg) {
1587
+ state.flush_outbuf(state.param,state.bs.out_buf, &state.bs.out_offset);
1588
+ state.bs.out_offset = len;
1589
+ state.flush_outbuf(state.param,block, &state.bs.out_offset);
1590
+ } else if (state.bs.out_offset + len > state.bs.out_size) {
1591
+ Assert(state,false,"output buffer too small for in-memory compression");
1592
+ } else {
1593
+ memcpy(state.bs.out_buf + state.bs.out_offset, block, len);
1594
+ state.bs.out_offset += len;
1595
+ }
1596
+ state.bs.bits_sent += (ulg)len<<3;
1597
+ }
1598
+
1599
+
1600
+
1601
+
1602
+
1603
+
1604
+
1605
+
1606
+ /* ===========================================================================
1607
+ * Prototypes for functions.
1608
+ */
1609
+
1610
+ void fill_window (TState &state);
1611
+ ulg deflate_fast (TState &state);
1612
+
1613
+ int longest_match (TState &state,IPos cur_match);
1614
+
1615
+
1616
+ /* ===========================================================================
1617
+ * Update a hash value with the given input byte
1618
+ * IN assertion: all calls to to UPDATE_HASH are made with consecutive
1619
+ * input characters, so that a running hash key can be computed from the
1620
+ * previous key instead of complete recalculation each time.
1621
+ */
1622
+ #define UPDATE_HASH(h,c) (h = (((h)<<H_SHIFT) ^ (c)) & HASH_MASK)
1623
+
1624
+ /* ===========================================================================
1625
+ * Insert string s in the dictionary and set match_head to the previous head
1626
+ * of the hash chain (the most recent string with same hash key). Return
1627
+ * the previous length of the hash chain.
1628
+ * IN assertion: all calls to to INSERT_STRING are made with consecutive
1629
+ * input characters and the first MIN_MATCH bytes of s are valid
1630
+ * (except for the last MIN_MATCH-1 bytes of the input file).
1631
+ */
1632
+ #define INSERT_STRING(s, match_head) \
1633
+ (UPDATE_HASH(state.ds.ins_h, state.ds.window[(s) + (MIN_MATCH-1)]), \
1634
+ state.ds.prev[(s) & WMASK] = match_head = state.ds.head[state.ds.ins_h], \
1635
+ state.ds.head[state.ds.ins_h] = (s))
1636
+
1637
+ /* ===========================================================================
1638
+ * Initialize the "longest match" routines for a new file
1639
+ *
1640
+ * IN assertion: window_size is > 0 if the input file is already read or
1641
+ * mmap'ed in the window[] array, 0 otherwise. In the first case,
1642
+ * window_size is sufficient to contain the whole input file plus
1643
+ * MIN_LOOKAHEAD bytes (to avoid referencing memory beyond the end
1644
+ * of window[] when looking for matches towards the end).
1645
+ */
1646
+ void lm_init (TState &state, int pack_level, ush *flags)
1647
+ {
1648
+ register unsigned j;
1649
+
1650
+ Assert(state,pack_level>=1 && pack_level<=8,"bad pack level");
1651
+
1652
+ /* Do not slide the window if the whole input is already in memory
1653
+ * (window_size > 0)
1654
+ */
1655
+ state.ds.sliding = 0;
1656
+ if (state.ds.window_size == 0L) {
1657
+ state.ds.sliding = 1;
1658
+ state.ds.window_size = (ulg)2L*WSIZE;
1659
+ }
1660
+
1661
+ /* Initialize the hash table (avoiding 64K overflow for 16 bit systems).
1662
+ * prev[] will be initialized on the fly.
1663
+ */
1664
+ state.ds.head[HASH_SIZE-1] = NIL;
1665
+ memset((char*)state.ds.head, NIL, (unsigned)(HASH_SIZE-1)*sizeof(*state.ds.head));
1666
+
1667
+ /* Set the default configuration parameters:
1668
+ */
1669
+ state.ds.max_lazy_match = configuration_table[pack_level].max_lazy;
1670
+ state.ds.good_match = configuration_table[pack_level].good_length;
1671
+ state.ds.nice_match = configuration_table[pack_level].nice_length;
1672
+ state.ds.max_chain_length = configuration_table[pack_level].max_chain;
1673
+ if (pack_level <= 2) {
1674
+ *flags |= FAST;
1675
+ } else if (pack_level >= 8) {
1676
+ *flags |= SLOW;
1677
+ }
1678
+ /* ??? reduce max_chain_length for binary files */
1679
+
1680
+ state.ds.strstart = 0;
1681
+ state.ds.block_start = 0L;
1682
+
1683
+ j = WSIZE;
1684
+ j <<= 1; // Can read 64K in one step
1685
+ state.ds.lookahead = state.readfunc(state, (char*)state.ds.window, j);
1686
+
1687
+ if (state.ds.lookahead == 0 || state.ds.lookahead == (unsigned)EOF) {
1688
+ state.ds.eofile = 1, state.ds.lookahead = 0;
1689
+ return;
1690
+ }
1691
+ state.ds.eofile = 0;
1692
+ /* Make sure that we always have enough lookahead. This is important
1693
+ * if input comes from a device such as a tty.
1694
+ */
1695
+ if (state.ds.lookahead < MIN_LOOKAHEAD) fill_window(state);
1696
+
1697
+ state.ds.ins_h = 0;
1698
+ for (j=0; j<MIN_MATCH-1; j++) UPDATE_HASH(state.ds.ins_h, state.ds.window[j]);
1699
+ /* If lookahead < MIN_MATCH, ins_h is garbage, but this is
1700
+ * not important since only literal bytes will be emitted.
1701
+ */
1702
+ }
1703
+
1704
+
1705
+ /* ===========================================================================
1706
+ * Set match_start to the longest match starting at the given string and
1707
+ * return its length. Matches shorter or equal to prev_length are discarded,
1708
+ * in which case the result is equal to prev_length and match_start is
1709
+ * garbage.
1710
+ * IN assertions: cur_match is the head of the hash chain for the current
1711
+ * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1
1712
+ */
1713
+ // For 80x86 and 680x0 and ARM, an optimized version is in match.asm or
1714
+ // match.S. The code is functionally equivalent, so you can use the C version
1715
+ // if desired. Which I do so desire!
1716
+ int longest_match(TState &state,IPos cur_match)
1717
+ {
1718
+ unsigned chain_length = state.ds.max_chain_length; /* max hash chain length */
1719
+ register uch *scan = state.ds.window + state.ds.strstart; /* current string */
1720
+ register uch *match; /* matched string */
1721
+ register int len; /* length of current match */
1722
+ int best_len = state.ds.prev_length; /* best match length so far */
1723
+ IPos limit = state.ds.strstart > (IPos)MAX_DIST ? state.ds.strstart - (IPos)MAX_DIST : NIL;
1724
+ /* Stop when cur_match becomes <= limit. To simplify the code,
1725
+ * we prevent matches with the string of window index 0.
1726
+ */
1727
+
1728
+ // The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
1729
+ // It is easy to get rid of this optimization if necessary.
1730
+ Assert(state,HASH_BITS>=8 && MAX_MATCH==258,"Code too clever");
1731
+
1732
+
1733
+
1734
+ register uch *strend = state.ds.window + state.ds.strstart + MAX_MATCH;
1735
+ register uch scan_end1 = scan[best_len-1];
1736
+ register uch scan_end = scan[best_len];
1737
+
1738
+ /* Do not waste too much time if we already have a good match: */
1739
+ if (state.ds.prev_length >= state.ds.good_match) {
1740
+ chain_length >>= 2;
1741
+ }
1742
+
1743
+ Assert(state,state.ds.strstart <= state.ds.window_size-MIN_LOOKAHEAD, "insufficient lookahead");
1744
+
1745
+ do {
1746
+ Assert(state,cur_match < state.ds.strstart, "no future");
1747
+ match = state.ds.window + cur_match;
1748
+
1749
+ /* Skip to next match if the match length cannot increase
1750
+ * or if the match length is less than 2:
1751
+ */
1752
+ if (match[best_len] != scan_end ||
1753
+ match[best_len-1] != scan_end1 ||
1754
+ *match != *scan ||
1755
+ *++match != scan[1]) continue;
1756
+
1757
+ /* The check at best_len-1 can be removed because it will be made
1758
+ * again later. (This heuristic is not always a win.)
1759
+ * It is not necessary to compare scan[2] and match[2] since they
1760
+ * are always equal when the other bytes match, given that
1761
+ * the hash keys are equal and that HASH_BITS >= 8.
1762
+ */
1763
+ scan += 2, match++;
1764
+
1765
+ /* We check for insufficient lookahead only every 8th comparison;
1766
+ * the 256th check will be made at strstart+258.
1767
+ */
1768
+ do {
1769
+ } while (*++scan == *++match && *++scan == *++match &&
1770
+ *++scan == *++match && *++scan == *++match &&
1771
+ *++scan == *++match && *++scan == *++match &&
1772
+ *++scan == *++match && *++scan == *++match &&
1773
+ scan < strend);
1774
+
1775
+ Assert(state,scan <= state.ds.window+(unsigned)(state.ds.window_size-1), "wild scan");
1776
+
1777
+ len = MAX_MATCH - (int)(strend - scan);
1778
+ scan = strend - MAX_MATCH;
1779
+
1780
+
1781
+ if (len > best_len) {
1782
+ state.ds.match_start = cur_match;
1783
+ best_len = len;
1784
+ if (len >= state.ds.nice_match) break;
1785
+ scan_end1 = scan[best_len-1];
1786
+ scan_end = scan[best_len];
1787
+ }
1788
+ } while ((cur_match = state.ds.prev[cur_match & WMASK]) > limit
1789
+ && --chain_length != 0);
1790
+
1791
+ return best_len;
1792
+ }
1793
+
1794
+
1795
+
1796
+ #define check_match(state,start, match, length)
1797
+ // or alternatively...
1798
+ //void check_match(TState &state,IPos start, IPos match, int length)
1799
+ //{ // check that the match is indeed a match
1800
+ // if (memcmp((char*)state.ds.window + match,
1801
+ // (char*)state.ds.window + start, length) != EQUAL) {
1802
+ // fprintf(stderr,
1803
+ // " start %d, match %d, length %d\n",
1804
+ // start, match, length);
1805
+ // error("invalid match");
1806
+ // }
1807
+ // if (state.verbose > 1) {
1808
+ // fprintf(stderr,"\\[%d,%d]", start-match, length);
1809
+ // do { fprintf(stdout,"%c",state.ds.window[start++]); } while (--length != 0);
1810
+ // }
1811
+ //}
1812
+
1813
+ /* ===========================================================================
1814
+ * Fill the window when the lookahead becomes insufficient.
1815
+ * Updates strstart and lookahead, and sets eofile if end of input file.
1816
+ *
1817
+ * IN assertion: lookahead < MIN_LOOKAHEAD && strstart + lookahead > 0
1818
+ * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
1819
+ * At least one byte has been read, or eofile is set; file reads are
1820
+ * performed for at least two bytes (required for the translate_eol option).
1821
+ */
1822
+ void fill_window(TState &state)
1823
+ {
1824
+ register unsigned n, m;
1825
+ unsigned more; /* Amount of free space at the end of the window. */
1826
+
1827
+ do {
1828
+ more = (unsigned)(state.ds.window_size - (ulg)state.ds.lookahead - (ulg)state.ds.strstart);
1829
+
1830
+ /* If the window is almost full and there is insufficient lookahead,
1831
+ * move the upper half to the lower one to make room in the upper half.
1832
+ */
1833
+ if (more == (unsigned)EOF) {
1834
+ /* Very unlikely, but possible on 16 bit machine if strstart == 0
1835
+ * and lookahead == 1 (input done one byte at time)
1836
+ */
1837
+ more--;
1838
+
1839
+ /* For MMAP or BIG_MEM, the whole input file is already in memory so
1840
+ * we must not perform sliding. We must however call (*read_buf)() in
1841
+ * order to compute the crc, update lookahead and possibly set eofile.
1842
+ */
1843
+ } else if (state.ds.strstart >= WSIZE+MAX_DIST && state.ds.sliding) {
1844
+
1845
+ /* By the IN assertion, the window is not empty so we can't confuse
1846
+ * more == 0 with more == 64K on a 16 bit machine.
1847
+ */
1848
+ memcpy((char*)state.ds.window, (char*)state.ds.window+WSIZE, (unsigned)WSIZE);
1849
+ state.ds.match_start -= WSIZE;
1850
+ state.ds.strstart -= WSIZE; /* we now have strstart >= MAX_DIST: */
1851
+
1852
+ state.ds.block_start -= (long) WSIZE;
1853
+
1854
+ for (n = 0; n < HASH_SIZE; n++) {
1855
+ m = state.ds.head[n];
1856
+ state.ds.head[n] = (Pos)(m >= WSIZE ? m-WSIZE : NIL);
1857
+ }
1858
+ for (n = 0; n < WSIZE; n++) {
1859
+ m = state.ds.prev[n];
1860
+ state.ds.prev[n] = (Pos)(m >= WSIZE ? m-WSIZE : NIL);
1861
+ /* If n is not on any hash chain, prev[n] is garbage but
1862
+ * its value will never be used.
1863
+ */
1864
+ }
1865
+ more += WSIZE;
1866
+ }
1867
+ if (state.ds.eofile) return;
1868
+
1869
+ /* If there was no sliding:
1870
+ * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&
1871
+ * more == window_size - lookahead - strstart
1872
+ * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
1873
+ * => more >= window_size - 2*WSIZE + 2
1874
+ * In the MMAP or BIG_MEM case (not yet supported in gzip),
1875
+ * window_size == input_size + MIN_LOOKAHEAD &&
1876
+ * strstart + lookahead <= input_size => more >= MIN_LOOKAHEAD.
1877
+ * Otherwise, window_size == 2*WSIZE so more >= 2.
1878
+ * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
1879
+ */
1880
+ Assert(state,more >= 2, "more < 2");
1881
+
1882
+ n = state.readfunc(state, (char*)state.ds.window+state.ds.strstart+state.ds.lookahead, more);
1883
+
1884
+ if (n == 0 || n == (unsigned)EOF) {
1885
+ state.ds.eofile = 1;
1886
+ } else {
1887
+ state.ds.lookahead += n;
1888
+ }
1889
+ } while (state.ds.lookahead < MIN_LOOKAHEAD && !state.ds.eofile);
1890
+ }
1891
+
1892
+ /* ===========================================================================
1893
+ * Flush the current block, with given end-of-file flag.
1894
+ * IN assertion: strstart is set to the end of the current match.
1895
+ */
1896
+ #define FLUSH_BLOCK(state,eof) \
1897
+ flush_block(state,state.ds.block_start >= 0L ? (char*)&state.ds.window[(unsigned)state.ds.block_start] : \
1898
+ (char*)NULL, (long)state.ds.strstart - state.ds.block_start, (eof))
1899
+
1900
+ /* ===========================================================================
1901
+ * Processes a new input file and return its compressed length. This
1902
+ * function does not perform lazy evaluation of matches and inserts
1903
+ * new strings in the dictionary only for unmatched strings or for short
1904
+ * matches. It is used only for the fast compression options.
1905
+ */
1906
+ ulg deflate_fast(TState &state)
1907
+ {
1908
+ IPos hash_head = NIL; /* head of the hash chain */
1909
+ int flush; /* set if current block must be flushed */
1910
+ unsigned match_length = 0; /* length of best match */
1911
+
1912
+ state.ds.prev_length = MIN_MATCH-1;
1913
+ while (state.ds.lookahead != 0) {
1914
+ /* Insert the string window[strstart .. strstart+2] in the
1915
+ * dictionary, and set hash_head to the head of the hash chain:
1916
+ */
1917
+ if (state.ds.lookahead >= MIN_MATCH)
1918
+ INSERT_STRING(state.ds.strstart, hash_head);
1919
+
1920
+ /* Find the longest match, discarding those <= prev_length.
1921
+ * At this point we have always match_length < MIN_MATCH
1922
+ */
1923
+ if (hash_head != NIL && state.ds.strstart - hash_head <= MAX_DIST) {
1924
+ /* To simplify the code, we prevent matches with the string
1925
+ * of window index 0 (in particular we have to avoid a match
1926
+ * of the string with itself at the start of the input file).
1927
+ */
1928
+ /* Do not look for matches beyond the end of the input.
1929
+ * This is necessary to make deflate deterministic.
1930
+ */
1931
+ if ((unsigned)state.ds.nice_match > state.ds.lookahead) state.ds.nice_match = (int)state.ds.lookahead;
1932
+ match_length = longest_match (state,hash_head);
1933
+ /* longest_match() sets match_start */
1934
+ if (match_length > state.ds.lookahead) match_length = state.ds.lookahead;
1935
+ }
1936
+ if (match_length >= MIN_MATCH) {
1937
+ check_match(state,state.ds.strstart, state.ds.match_start, match_length);
1938
+
1939
+ flush = ct_tally(state,state.ds.strstart-state.ds.match_start, match_length - MIN_MATCH);
1940
+
1941
+ state.ds.lookahead -= match_length;
1942
+
1943
+ /* Insert new strings in the hash table only if the match length
1944
+ * is not too large. This saves time but degrades compression.
1945
+ */
1946
+ if (match_length <= state.ds.max_insert_length
1947
+ && state.ds.lookahead >= MIN_MATCH) {
1948
+ match_length--; /* string at strstart already in hash table */
1949
+ do {
1950
+ state.ds.strstart++;
1951
+ INSERT_STRING(state.ds.strstart, hash_head);
1952
+ /* strstart never exceeds WSIZE-MAX_MATCH, so there are
1953
+ * always MIN_MATCH bytes ahead.
1954
+ */
1955
+ } while (--match_length != 0);
1956
+ state.ds.strstart++;
1957
+ } else {
1958
+ state.ds.strstart += match_length;
1959
+ match_length = 0;
1960
+ state.ds.ins_h = state.ds.window[state.ds.strstart];
1961
+ UPDATE_HASH(state.ds.ins_h, state.ds.window[state.ds.strstart+1]);
1962
+ Assert(state,MIN_MATCH==3,"Call UPDATE_HASH() MIN_MATCH-3 more times");
1963
+ }
1964
+ } else {
1965
+ /* No match, output a literal byte */
1966
+ flush = ct_tally (state,0, state.ds.window[state.ds.strstart]);
1967
+ state.ds.lookahead--;
1968
+ state.ds.strstart++;
1969
+ }
1970
+ if (flush) FLUSH_BLOCK(state,0), state.ds.block_start = state.ds.strstart;
1971
+
1972
+ /* Make sure that we always have enough lookahead, except
1973
+ * at the end of the input file. We need MAX_MATCH bytes
1974
+ * for the next match, plus MIN_MATCH bytes to insert the
1975
+ * string following the next match.
1976
+ */
1977
+ if (state.ds.lookahead < MIN_LOOKAHEAD) fill_window(state);
1978
+ }
1979
+ return FLUSH_BLOCK(state,1); /* eof */
1980
+ }
1981
+
1982
+ /* ===========================================================================
1983
+ * Same as above, but achieves better compression. We use a lazy
1984
+ * evaluation for matches: a match is finally adopted only if there is
1985
+ * no better match at the next window position.
1986
+ */
1987
+ ulg deflate(TState &state)
1988
+ {
1989
+ IPos hash_head = NIL; /* head of hash chain */
1990
+ IPos prev_match; /* previous match */
1991
+ int flush; /* set if current block must be flushed */
1992
+ int match_available = 0; /* set if previous match exists */
1993
+ register unsigned match_length = MIN_MATCH-1; /* length of best match */
1994
+
1995
+ if (state.level <= 3) return deflate_fast(state); /* optimized for speed */
1996
+
1997
+ /* Process the input block. */
1998
+ while (state.ds.lookahead != 0) {
1999
+ /* Insert the string window[strstart .. strstart+2] in the
2000
+ * dictionary, and set hash_head to the head of the hash chain:
2001
+ */
2002
+ if (state.ds.lookahead >= MIN_MATCH)
2003
+ INSERT_STRING(state.ds.strstart, hash_head);
2004
+
2005
+ /* Find the longest match, discarding those <= prev_length.
2006
+ */
2007
+ state.ds.prev_length = match_length, prev_match = state.ds.match_start;
2008
+ match_length = MIN_MATCH-1;
2009
+
2010
+ if (hash_head != NIL && state.ds.prev_length < state.ds.max_lazy_match &&
2011
+ state.ds.strstart - hash_head <= MAX_DIST) {
2012
+ /* To simplify the code, we prevent matches with the string
2013
+ * of window index 0 (in particular we have to avoid a match
2014
+ * of the string with itself at the start of the input file).
2015
+ */
2016
+ /* Do not look for matches beyond the end of the input.
2017
+ * This is necessary to make deflate deterministic.
2018
+ */
2019
+ if ((unsigned)state.ds.nice_match > state.ds.lookahead) state.ds.nice_match = (int)state.ds.lookahead;
2020
+ match_length = longest_match (state,hash_head);
2021
+ /* longest_match() sets match_start */
2022
+ if (match_length > state.ds.lookahead) match_length = state.ds.lookahead;
2023
+
2024
+ /* Ignore a length 3 match if it is too distant: */
2025
+ if (match_length == MIN_MATCH && state.ds.strstart-state.ds.match_start > TOO_FAR){
2026
+ /* If prev_match is also MIN_MATCH, match_start is garbage
2027
+ * but we will ignore the current match anyway.
2028
+ */
2029
+ match_length = MIN_MATCH-1;
2030
+ }
2031
+ }
2032
+ /* If there was a match at the previous step and the current
2033
+ * match is not better, output the previous match:
2034
+ */
2035
+ if (state.ds.prev_length >= MIN_MATCH && match_length <= state.ds.prev_length) {
2036
+ unsigned max_insert = state.ds.strstart + state.ds.lookahead - MIN_MATCH;
2037
+ check_match(state,state.ds.strstart-1, prev_match, state.ds.prev_length);
2038
+ flush = ct_tally(state,state.ds.strstart-1-prev_match, state.ds.prev_length - MIN_MATCH);
2039
+
2040
+ /* Insert in hash table all strings up to the end of the match.
2041
+ * strstart-1 and strstart are already inserted.
2042
+ */
2043
+ state.ds.lookahead -= state.ds.prev_length-1;
2044
+ state.ds.prev_length -= 2;
2045
+ do {
2046
+ if (++state.ds.strstart <= max_insert) {
2047
+ INSERT_STRING(state.ds.strstart, hash_head);
2048
+ /* strstart never exceeds WSIZE-MAX_MATCH, so there are
2049
+ * always MIN_MATCH bytes ahead.
2050
+ */
2051
+ }
2052
+ } while (--state.ds.prev_length != 0);
2053
+ state.ds.strstart++;
2054
+ match_available = 0;
2055
+ match_length = MIN_MATCH-1;
2056
+
2057
+ if (flush) FLUSH_BLOCK(state,0), state.ds.block_start = state.ds.strstart;
2058
+
2059
+ } else if (match_available) {
2060
+ /* If there was no match at the previous position, output a
2061
+ * single literal. If there was a match but the current match
2062
+ * is longer, truncate the previous match to a single literal.
2063
+ */
2064
+ if (ct_tally (state,0, state.ds.window[state.ds.strstart-1])) {
2065
+ FLUSH_BLOCK(state,0), state.ds.block_start = state.ds.strstart;
2066
+ }
2067
+ state.ds.strstart++;
2068
+ state.ds.lookahead--;
2069
+ } else {
2070
+ /* There is no previous match to compare with, wait for
2071
+ * the next step to decide.
2072
+ */
2073
+ match_available = 1;
2074
+ state.ds.strstart++;
2075
+ state.ds.lookahead--;
2076
+ }
2077
+ // Assert(state,strstart <= isize && lookahead <= isize, "a bit too far");
2078
+
2079
+ /* Make sure that we always have enough lookahead, except
2080
+ * at the end of the input file. We need MAX_MATCH bytes
2081
+ * for the next match, plus MIN_MATCH bytes to insert the
2082
+ * string following the next match.
2083
+ */
2084
+ if (state.ds.lookahead < MIN_LOOKAHEAD) fill_window(state);
2085
+ }
2086
+ if (match_available) ct_tally (state,0, state.ds.window[state.ds.strstart-1]);
2087
+
2088
+ return FLUSH_BLOCK(state,1); /* eof */
2089
+ }
2090
+
2091
+
2092
+
2093
+
2094
+
2095
+
2096
+
2097
+
2098
+
2099
+
2100
+
2101
+
2102
+ int putlocal(struct zlist *z, WRITEFUNC wfunc,void *param)
2103
+ { // Write a local header described by *z to file *f. Return a ZE_ error code.
2104
+ PUTLG(LOCSIG, f);
2105
+ PUTSH(z->ver, f);
2106
+ PUTSH(z->lflg, f);
2107
+ PUTSH(z->how, f);
2108
+ PUTLG(z->tim, f);
2109
+ PUTLG(z->crc, f);
2110
+ PUTLG(z->siz, f);
2111
+ PUTLG(z->len, f);
2112
+ PUTSH(z->nam, f);
2113
+ PUTSH(z->ext, f);
2114
+ size_t res = (size_t)wfunc(param, z->iname, (unsigned int)z->nam);
2115
+ if (res!=z->nam) return ZE_TEMP;
2116
+ if (z->ext)
2117
+ { res = (size_t)wfunc(param, z->extra, (unsigned int)z->ext);
2118
+ if (res!=z->ext) return ZE_TEMP;
2119
+ }
2120
+ return ZE_OK;
2121
+ }
2122
+
2123
+ int putextended(struct zlist *z, WRITEFUNC wfunc, void *param)
2124
+ { // Write an extended local header described by *z to file *f. Returns a ZE_ code
2125
+ PUTLG(EXTLOCSIG, f);
2126
+ PUTLG(z->crc, f);
2127
+ PUTLG(z->siz, f);
2128
+ PUTLG(z->len, f);
2129
+ return ZE_OK;
2130
+ }
2131
+
2132
+ int putcentral(struct zlist *z, WRITEFUNC wfunc, void *param)
2133
+ { // Write a central header entry of *z to file *f. Returns a ZE_ code.
2134
+ PUTLG(CENSIG, f);
2135
+ PUTSH(z->vem, f);
2136
+ PUTSH(z->ver, f);
2137
+ PUTSH(z->flg, f);
2138
+ PUTSH(z->how, f);
2139
+ PUTLG(z->tim, f);
2140
+ PUTLG(z->crc, f);
2141
+ PUTLG(z->siz, f);
2142
+ PUTLG(z->len, f);
2143
+ PUTSH(z->nam, f);
2144
+ PUTSH(z->cext, f);
2145
+ PUTSH(z->com, f);
2146
+ PUTSH(z->dsk, f);
2147
+ PUTSH(z->att, f);
2148
+ PUTLG(z->atx, f);
2149
+ PUTLG(z->off, f);
2150
+ if ((size_t)wfunc(param, z->iname, (unsigned int)z->nam) != z->nam ||
2151
+ (z->cext && (size_t)wfunc(param, z->cextra, (unsigned int)z->cext) != z->cext) ||
2152
+ (z->com && (size_t)wfunc(param, z->comment, (unsigned int)z->com) != z->com))
2153
+ return ZE_TEMP;
2154
+ return ZE_OK;
2155
+ }
2156
+
2157
+
2158
+ int putend(int n, ulg s, ulg c, extent m, char *z, WRITEFUNC wfunc, void *param)
2159
+ { // write the end of the central-directory-data to file *f.
2160
+ PUTLG(ENDSIG, f);
2161
+ PUTSH(0, f);
2162
+ PUTSH(0, f);
2163
+ PUTSH(n, f);
2164
+ PUTSH(n, f);
2165
+ PUTLG(s, f);
2166
+ PUTLG(c, f);
2167
+ PUTSH(m, f);
2168
+ // Write the comment, if any
2169
+ if (m && wfunc(param, z, (unsigned int)m) != m) return ZE_TEMP;
2170
+ return ZE_OK;
2171
+ }
2172
+
2173
+
2174
+
2175
+
2176
+
2177
+
2178
+ const ulg crc_table[256] = {
2179
+ 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
2180
+ 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
2181
+ 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
2182
+ 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
2183
+ 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
2184
+ 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
2185
+ 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
2186
+ 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
2187
+ 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
2188
+ 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
2189
+ 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
2190
+ 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
2191
+ 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
2192
+ 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
2193
+ 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
2194
+ 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
2195
+ 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
2196
+ 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
2197
+ 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
2198
+ 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
2199
+ 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
2200
+ 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
2201
+ 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
2202
+ 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
2203
+ 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
2204
+ 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
2205
+ 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
2206
+ 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
2207
+ 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
2208
+ 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
2209
+ 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
2210
+ 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
2211
+ 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
2212
+ 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
2213
+ 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
2214
+ 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
2215
+ 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
2216
+ 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
2217
+ 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
2218
+ 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
2219
+ 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
2220
+ 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
2221
+ 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
2222
+ 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
2223
+ 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
2224
+ 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
2225
+ 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
2226
+ 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
2227
+ 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
2228
+ 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
2229
+ 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
2230
+ 0x2d02ef8dL
2231
+ };
2232
+
2233
+ #define CRC32(c, b) (crc_table[((int)(c) ^ (b)) & 0xff] ^ ((c) >> 8))
2234
+ #define DO1(buf) crc = CRC32(crc, *buf++)
2235
+ #define DO2(buf) DO1(buf); DO1(buf)
2236
+ #define DO4(buf) DO2(buf); DO2(buf)
2237
+ #define DO8(buf) DO4(buf); DO4(buf)
2238
+
2239
+ ulg crc32(ulg crc, const uch *buf, extent len)
2240
+ { if (buf==NULL) return 0L;
2241
+ crc = crc ^ 0xffffffffL;
2242
+ while (len >= 8) {DO8(buf); len -= 8;}
2243
+ if (len) do {DO1(buf);} while (--len);
2244
+ return crc ^ 0xffffffffL; // (instead of ~c for 64-bit machines)
2245
+ }
2246
+
2247
+
2248
+ void update_keys(unsigned long *keys, char c)
2249
+ { keys[0] = CRC32(keys[0],c);
2250
+ keys[1] += keys[0] & 0xFF;
2251
+ keys[1] = keys[1]*134775813L +1;
2252
+ keys[2] = CRC32(keys[2], keys[1] >> 24);
2253
+ }
2254
+ char decrypt_byte(unsigned long *keys)
2255
+ { unsigned temp = ((unsigned)keys[2] & 0xffff) | 2;
2256
+ return (char)(((temp * (temp ^ 1)) >> 8) & 0xff);
2257
+ }
2258
+ char zencode(unsigned long *keys, char c)
2259
+ { int t=decrypt_byte(keys);
2260
+ update_keys(keys,c);
2261
+ return (char)(t^c);
2262
+ }
2263
+
2264
+
2265
+
2266
+
2267
+
2268
+
2269
+
2270
+ int lustricmp(const TCHAR *sa, const TCHAR *sb)
2271
+ { for (const TCHAR *ca=sa, *cb=sb; ; ca++, cb++)
2272
+ { int ia=tolower(*ca), ib=tolower(*cb);
2273
+ if (ia==ib && ia==0) return 0;
2274
+ if (ia==ib) continue;
2275
+ if (ia<ib) return -1;
2276
+ if (ia>ib) return 1;
2277
+ }
2278
+ }
2279
+
2280
+
2281
+ bool HasZipSuffix(const TCHAR *fn)
2282
+ { const TCHAR *ext = fn+_tcslen(fn);
2283
+ while (ext>fn && *ext!='.') ext--;
2284
+ if (ext==fn && *ext!='.') return false;
2285
+ if (lustricmp(ext,_T(".Z"))==0) return true;
2286
+ if (lustricmp(ext,_T(".zip"))==0) return true;
2287
+ if (lustricmp(ext,_T(".zoo"))==0) return true;
2288
+ if (lustricmp(ext,_T(".arc"))==0) return true;
2289
+ if (lustricmp(ext,_T(".lzh"))==0) return true;
2290
+ if (lustricmp(ext,_T(".arj"))==0) return true;
2291
+ if (lustricmp(ext,_T(".gz"))==0) return true;
2292
+ if (lustricmp(ext,_T(".tgz"))==0) return true;
2293
+ return false;
2294
+ }
2295
+
2296
+
2297
+
2298
+
2299
+
2300
+
2301
+
2302
+
2303
+ class TZip
2304
+ { public:
2305
+ TZip(const char *pwd) : hfout(0),mustclosehfout(false),hmapout(0),zfis(0),obuf(0),hfin(0),writ(0),oerr(false),hasputcen(false),ooffset(0),encwriting(false),encbuf(0),password(0), state(0) {if (pwd!=0 && *pwd!=0) {password=new char[strlen(pwd)+1]; strcpy(password,pwd);}}
2306
+ ~TZip() {if (state!=0) delete state; state=0; if (encbuf!=0) delete[] encbuf; encbuf=0; if (password!=0) delete[] password; password=0;}
2307
+
2308
+ // These variables say about the file we're writing into
2309
+ // We can write to pipe, file-by-handle, file-by-name, memory-to-memmapfile
2310
+ char *password; // keep a copy of the password
2311
+ HANDLE hfout; // if valid, we'll write here (for files or pipes)
2312
+ bool mustclosehfout; // if true, we are responsible for closing hfout
2313
+ HANDLE hmapout; // otherwise, we'll write here (for memmap)
2314
+ unsigned ooffset; // for hfout, this is where the pointer was initially
2315
+ ZRESULT oerr; // did a write operation give rise to an error?
2316
+ unsigned writ; // how far have we written. This is maintained by Add, not write(), to avoid confusion over seeks
2317
+ bool ocanseek; // can we seek?
2318
+ char *obuf; // this is where we've locked mmap to view.
2319
+ unsigned int opos; // current pos in the mmap
2320
+ unsigned int mapsize; // the size of the map we created
2321
+ bool hasputcen; // have we yet placed the central directory?
2322
+ bool encwriting; // if true, then we'll encrypt stuff using 'keys' before we write it to disk
2323
+ unsigned long keys[3]; // keys are initialised inside Add()
2324
+ char *encbuf; // if encrypting, then this is a temporary workspace for encrypting the data
2325
+ unsigned int encbufsize; // (to be used and resized inside write(), and deleted in the destructor)
2326
+ //
2327
+ TZipFileInfo *zfis; // each file gets added onto this list, for writing the table at the end
2328
+ TState *state; // we use just one state object per zip, because it's big (500k)
2329
+
2330
+ ZRESULT Create(void *z,unsigned int len,DWORD flags);
2331
+ static unsigned sflush(void *param,const char *buf, unsigned *size);
2332
+ static unsigned swrite(void *param,const char *buf, unsigned size);
2333
+ unsigned int write(const char *buf,unsigned int size);
2334
+ bool oseek(unsigned int pos);
2335
+ ZRESULT GetMemory(void **pbuf, unsigned long *plen);
2336
+ ZRESULT Close();
2337
+
2338
+ // some variables to do with the file currently being read:
2339
+ // I haven't done it object-orientedly here, just put them all
2340
+ // together, since OO didn't seem to make the design any clearer.
2341
+ ulg attr; iztimes times; ulg timestamp; // all open_* methods set these
2342
+ bool iseekable; long isize,ired; // size is not set until close() on pips
2343
+ ulg crc; // crc is not set until close(). iwrit is cumulative
2344
+ HANDLE hfin; bool selfclosehf; // for input files and pipes
2345
+ const char *bufin; unsigned int lenin,posin; // for memory
2346
+ // and a variable for what we've done with the input: (i.e. compressed it!)
2347
+ ulg csize; // compressed size, set by the compression routines
2348
+ // and this is used by some of the compression routines
2349
+ char buf[16384];
2350
+
2351
+
2352
+ ZRESULT open_file(const TCHAR *fn);
2353
+ ZRESULT open_handle(HANDLE hf,unsigned int len);
2354
+ ZRESULT open_mem(void *src,unsigned int len);
2355
+ ZRESULT open_dir();
2356
+ static unsigned sread(TState &s,char *buf,unsigned size);
2357
+ unsigned read(char *buf, unsigned size);
2358
+ ZRESULT iclose();
2359
+
2360
+ ZRESULT ideflate(TZipFileInfo *zfi);
2361
+ ZRESULT istore();
2362
+
2363
+ ZRESULT Add(const TCHAR *odstzn, void *src,unsigned int len, DWORD flags);
2364
+ ZRESULT AddCentral();
2365
+
2366
+ };
2367
+
2368
+
2369
+
2370
+ ZRESULT TZip::Create(void *z,unsigned int len,DWORD flags)
2371
+ { if (hfout!=0 || hmapout!=0 || obuf!=0 || writ!=0 || oerr!=ZR_OK || hasputcen) return ZR_NOTINITED;
2372
+ //
2373
+ if (flags==ZIP_HANDLE)
2374
+ { HANDLE hf = (HANDLE)z;
2375
+ hfout=hf; mustclosehfout=false;
2376
+ #ifdef DuplicateHandle
2377
+ BOOL res = DuplicateHandle(GetCurrentProcess(),hf,GetCurrentProcess(),&hfout,0,FALSE,DUPLICATE_SAME_ACCESS);
2378
+ if (res) mustclosehandle=true;
2379
+ #endif
2380
+ // now we have hfout. Either we duplicated the handle and we close it ourselves
2381
+ // (while the caller closes h themselves), or we couldn't duplicate it.
2382
+ DWORD res=GetFilePosZ(hfout);
2383
+ ocanseek = (res!=0xFFFFFFFF);
2384
+ ooffset = ocanseek ? res : 0;
2385
+ return ZR_OK;
2386
+ }
2387
+ else if (flags==ZIP_FILENAME)
2388
+ { const TCHAR *fn = (const TCHAR*)z;
2389
+ #ifdef ZIP_STD
2390
+ hfout = fopen(fn,"wb");
2391
+ if (hfout==0) return ZR_NOFILE;
2392
+ #else
2393
+ hfout = CreateFile(fn,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
2394
+ if (hfout==INVALID_HANDLE_VALUE) {hfout=0; return ZR_NOFILE;}
2395
+ #endif
2396
+ ocanseek=true;
2397
+ ooffset=0;
2398
+ mustclosehfout=true;
2399
+ return ZR_OK;
2400
+ }
2401
+ else if (flags==ZIP_MEMORY)
2402
+ { unsigned int size = len;
2403
+ if (size==0) return ZR_MEMSIZE;
2404
+ #ifdef ZIP_STD
2405
+ if (z!=0) obuf=(char*)z;
2406
+ else return ZR_ARGS;
2407
+ #else
2408
+ if (z!=0) obuf=(char*)z;
2409
+ else
2410
+ { hmapout = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE,0,size,NULL);
2411
+ if (hmapout==NULL) return ZR_NOALLOC;
2412
+ obuf = (char*)MapViewOfFile(hmapout,FILE_MAP_ALL_ACCESS,0,0,size);
2413
+ if (obuf==0) {CloseHandle(hmapout); hmapout=0; return ZR_NOALLOC;}
2414
+ }
2415
+ #endif
2416
+ ocanseek=true;
2417
+ opos=0; mapsize=size;
2418
+ return ZR_OK;
2419
+ }
2420
+ else return ZR_ARGS;
2421
+ }
2422
+
2423
+ unsigned TZip::sflush(void *param,const char *buf, unsigned *size)
2424
+ { // static
2425
+ if (*size==0) return 0;
2426
+ TZip *zip = (TZip*)param;
2427
+ unsigned int writ = zip->write(buf,*size);
2428
+ if (writ!=0) *size=0;
2429
+ return writ;
2430
+ }
2431
+ unsigned TZip::swrite(void *param,const char *buf, unsigned size)
2432
+ { // static
2433
+ if (size==0) return 0;
2434
+ TZip *zip=(TZip*)param; return zip->write(buf,size);
2435
+ }
2436
+ unsigned int TZip::write(const char *buf,unsigned int size)
2437
+ { const char *srcbuf=buf;
2438
+ if (encwriting)
2439
+ { if (encbuf!=0 && encbufsize<size) {delete[] encbuf; encbuf=0;}
2440
+ if (encbuf==0) {encbuf=new char[size*2]; encbufsize=size;}
2441
+ memcpy(encbuf,buf,size);
2442
+ for (unsigned int i=0; i<size; i++) encbuf[i]=zencode(keys,encbuf[i]);
2443
+ srcbuf=encbuf;
2444
+ }
2445
+ if (obuf!=0)
2446
+ { if (opos+size>=mapsize) {oerr=ZR_MEMSIZE; return 0;}
2447
+ memcpy(obuf+opos, srcbuf, size);
2448
+ opos+=size;
2449
+ return size;
2450
+ }
2451
+ else if (hfout!=0)
2452
+ {
2453
+ #ifdef ZIP_STD
2454
+ DWORD writ=(DWORD)fwrite(srcbuf,1,size,hfout);
2455
+ #else
2456
+ DWORD writ; WriteFile(hfout,srcbuf,size,&writ,NULL);
2457
+ #endif
2458
+ return writ;
2459
+ }
2460
+ oerr=ZR_NOTINITED; return 0;
2461
+ }
2462
+
2463
+ bool TZip::oseek(unsigned int pos)
2464
+ { if (!ocanseek) {oerr=ZR_SEEK; return false;}
2465
+ if (obuf!=0)
2466
+ { if (pos>=mapsize) {oerr=ZR_MEMSIZE; return false;}
2467
+ opos=pos;
2468
+ return true;
2469
+ }
2470
+ else if (hfout!=0)
2471
+ {
2472
+ #ifdef ZIP_STD
2473
+ fseek(hfout,pos+ooffset,SEEK_SET);
2474
+ #else
2475
+ SetFilePointer(hfout,pos+ooffset,NULL,FILE_BEGIN);
2476
+ #endif
2477
+ return true;
2478
+ }
2479
+ oerr=ZR_NOTINITED; return 0;
2480
+ }
2481
+
2482
+ ZRESULT TZip::GetMemory(void **pbuf, unsigned long *plen)
2483
+ { // When the user calls GetMemory, they're presumably at the end
2484
+ // of all their adding. In any case, we have to add the central
2485
+ // directory now, otherwise the memory we tell them won't be complete.
2486
+ if (!hasputcen) AddCentral(); hasputcen=true;
2487
+ if (pbuf!=NULL) *pbuf=(void*)obuf;
2488
+ if (plen!=NULL) *plen=writ;
2489
+ if (obuf==NULL) return ZR_NOTMMAP;
2490
+ return ZR_OK;
2491
+ }
2492
+
2493
+ ZRESULT TZip::Close()
2494
+ { // if the directory hadn't already been added through a call to GetMemory,
2495
+ // then we do it now
2496
+ ZRESULT res=ZR_OK; if (!hasputcen) res=AddCentral(); hasputcen=true;
2497
+ #ifdef ZIP_STD
2498
+ if (hfout!=0 && mustclosehfout) fclose(hfout); hfout=0; mustclosehfout=false;
2499
+ #else
2500
+ if (obuf!=0 && hmapout!=0) UnmapViewOfFile(obuf); obuf=0;
2501
+ if (hmapout!=0) CloseHandle(hmapout); hmapout=0;
2502
+ if (hfout!=0 && mustclosehfout) CloseHandle(hfout); hfout=0; mustclosehfout=false;
2503
+ #endif
2504
+ return res;
2505
+ }
2506
+
2507
+
2508
+
2509
+
2510
+ ZRESULT TZip::open_file(const TCHAR *fn)
2511
+ { hfin=0; bufin=0; selfclosehf=false; crc=CRCVAL_INITIAL; isize=0; csize=0; ired=0;
2512
+ if (fn==0) return ZR_ARGS;
2513
+ #ifdef ZIP_STD
2514
+ HANDLE hf = fopen(fn,"rb");
2515
+ if (hf==0) return ZR_NOFILE;
2516
+ ZRESULT res = open_handle(hf,0);
2517
+ if (res!=ZR_OK) {fclose(hf); return res;}
2518
+ #else
2519
+ HANDLE hf = CreateFile(fn,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL);
2520
+ if (hf==INVALID_HANDLE_VALUE) return ZR_NOFILE;
2521
+ ZRESULT res = open_handle(hf,0);
2522
+ if (res!=ZR_OK) {CloseHandle(hf); return res;}
2523
+ #endif
2524
+ selfclosehf=true;
2525
+ return ZR_OK;
2526
+ }
2527
+ ZRESULT TZip::open_handle(HANDLE hf,unsigned int len)
2528
+ { hfin=0; bufin=0; selfclosehf=false; crc=CRCVAL_INITIAL; isize=0; csize=0; ired=0;
2529
+ if (hf==0 || hf==INVALID_HANDLE_VALUE) return ZR_ARGS;
2530
+ bool canseek;
2531
+ #ifdef ZIP_STD
2532
+ struct stat st; fstat(fileno(hf),&st); canseek = S_ISREG(st.st_mode);
2533
+ #else
2534
+ DWORD res = SetFilePointer(hfout,0,0,FILE_CURRENT);
2535
+ canseek = (res!=0xFFFFFFFF);
2536
+ #endif
2537
+ if (canseek)
2538
+ { ZRESULT res = GetFileInfo(hf,&attr,&isize,&times,&timestamp);
2539
+ if (res!=ZR_OK) return res;
2540
+ #ifdef ZIP_STD
2541
+ fseek(hf,0,SEEK_SET);
2542
+ #else
2543
+ SetFilePointer(hf,0,NULL,FILE_BEGIN); // because GetFileInfo will have screwed it up
2544
+ #endif
2545
+ iseekable=true; hfin=hf;
2546
+ return ZR_OK;
2547
+ }
2548
+ else
2549
+ { attr= 0x80000000; // just a normal file
2550
+ isize = -1; // can't know size until at the end
2551
+ if (len!=0) isize=len; // unless we were told explicitly!
2552
+ iseekable=false;
2553
+ WORD dosdate, dostime; GetNow(&times.atime, &dosdate, &dostime);
2554
+ times.mtime=times.atime;
2555
+ times.ctime=times.atime;
2556
+ timestamp = (WORD)dostime | (((DWORD)dosdate)<<16);
2557
+ hfin=hf;
2558
+ return ZR_OK;
2559
+ }
2560
+ }
2561
+ ZRESULT TZip::open_mem(void *src,unsigned int len)
2562
+ { hfin=0; bufin=(const char*)src; selfclosehf=false; crc=CRCVAL_INITIAL; ired=0; csize=0; ired=0;
2563
+ lenin=len; posin=0;
2564
+ if (src==0 || len==0) return ZR_ARGS;
2565
+ attr= 0x80000000; // just a normal file
2566
+ isize = len;
2567
+ iseekable=true;
2568
+ WORD dosdate, dostime; GetNow(&times.atime, &dosdate, &dostime);
2569
+ times.mtime=times.atime;
2570
+ times.ctime=times.atime;
2571
+ timestamp = (WORD)dostime | (((DWORD)dosdate)<<16);
2572
+ return ZR_OK;
2573
+ }
2574
+ ZRESULT TZip::open_dir()
2575
+ { hfin=0; bufin=0; selfclosehf=false; crc=CRCVAL_INITIAL; isize=0; csize=0; ired=0;
2576
+ attr= 0x41C00010; // a readable writable directory, and again directory
2577
+ isize = 0;
2578
+ iseekable=false;
2579
+ WORD dosdate, dostime; GetNow(&times.atime, &dosdate, &dostime);
2580
+ times.mtime=times.atime;
2581
+ times.ctime=times.atime;
2582
+ timestamp = (WORD)dostime | (((DWORD)dosdate)<<16);
2583
+ return ZR_OK;
2584
+ }
2585
+
2586
+ unsigned TZip::sread(TState &s,char *buf,unsigned size)
2587
+ { // static
2588
+ TZip *zip = (TZip*)s.param;
2589
+ return zip->read(buf,size);
2590
+ }
2591
+
2592
+ unsigned TZip::read(char *buf, unsigned size)
2593
+ { if (bufin!=0)
2594
+ { if (posin>=lenin) return 0; // end of input
2595
+ ulg red = lenin-posin;
2596
+ if (red>size) red=size;
2597
+ memcpy(buf, bufin+posin, red);
2598
+ posin += red;
2599
+ ired += red;
2600
+ crc = crc32(crc, (uch*)buf, red);
2601
+ return red;
2602
+ }
2603
+ else if (hfin!=0)
2604
+ { DWORD red;
2605
+ #ifdef ZIP_STD
2606
+ red = (DWORD)fread(buf,1,size,hfin);
2607
+ if (red==0) return 0;
2608
+ #else
2609
+ BOOL ok = ReadFile(hfin,buf,size,&red,NULL);
2610
+ if (!ok) return 0;
2611
+ #endif
2612
+ ired += red;
2613
+ crc = crc32(crc, (uch*)buf, red);
2614
+ return red;
2615
+ }
2616
+ else {oerr=ZR_NOTINITED; return 0;}
2617
+ }
2618
+
2619
+ ZRESULT TZip::iclose()
2620
+ {
2621
+ #ifdef ZIP_STD
2622
+ if (selfclosehf && hfin!=0) fclose(hfin); hfin=0;
2623
+ #else
2624
+ if (selfclosehf && hfin!=0) CloseHandle(hfin); hfin=0;
2625
+ #endif
2626
+ bool mismatch = (isize!=-1 && isize!=ired);
2627
+ isize=ired; // and crc has been being updated anyway
2628
+ if (mismatch) return ZR_MISSIZE;
2629
+ else return ZR_OK;
2630
+ }
2631
+
2632
+
2633
+
2634
+ ZRESULT TZip::ideflate(TZipFileInfo *zfi)
2635
+ { if (state==0) state=new TState();
2636
+ // It's a very big object! 500k! We allocate it on the heap, because PocketPC's
2637
+ // stack breaks if we try to put it all on the stack. It will be deleted lazily
2638
+ state->err=0;
2639
+ state->readfunc=sread; state->flush_outbuf=sflush;
2640
+ state->param=this; state->level=8; state->seekable=iseekable; state->err=NULL;
2641
+ // the following line will make ct_init realise it has to perform the init
2642
+ state->ts.static_dtree[0].dl.len = 0;
2643
+ // Thanks to Alvin77 for this crucial fix:
2644
+ state->ds.window_size=0;
2645
+ // I think that covers everything that needs to be initted.
2646
+ //
2647
+ bi_init(*state,buf, sizeof(buf), 1); // it used to be just 1024-size, not 16384 as here
2648
+ ct_init(*state,&zfi->att);
2649
+ lm_init(*state,state->level, &zfi->flg);
2650
+ ulg sz = deflate(*state);
2651
+ csize=sz;
2652
+ ZRESULT r=ZR_OK; if (state->err!=NULL) r=ZR_FLATE;
2653
+ return r;
2654
+ }
2655
+
2656
+ ZRESULT TZip::istore()
2657
+ { ulg size=0;
2658
+ for (;;)
2659
+ { unsigned int cin=read(buf,16384); if (cin<=0 || cin==(unsigned int)EOF) break;
2660
+ unsigned int cout = write(buf,cin); if (cout!=cin) return ZR_MISSIZE;
2661
+ size += cin;
2662
+ }
2663
+ csize=size;
2664
+ return ZR_OK;
2665
+ }
2666
+
2667
+
2668
+
2669
+
2670
+
2671
+ bool has_seeded=false;
2672
+ ZRESULT TZip::Add(const TCHAR *odstzn, void *src,unsigned int len, DWORD flags)
2673
+ { if (oerr) return ZR_FAILED;
2674
+ if (hasputcen) return ZR_ENDED;
2675
+
2676
+ // if we use password encryption, then every isize and csize is 12 bytes bigger
2677
+ int passex=0; if (password!=0 && flags!=ZIP_FOLDER) passex=12;
2678
+
2679
+ // zip has its own notion of what its names should look like: i.e. dir/file.stuff
2680
+ TCHAR dstzn[MAX_PATH]; _tcsncpy(dstzn,odstzn,MAX_PATH); dstzn[MAX_PATH-1]=0;
2681
+ if (*dstzn==0) return ZR_ARGS;
2682
+ TCHAR *d=dstzn; while (*d!=0) {if (*d=='\\') *d='/'; d++;}
2683
+ bool isdir = (flags==ZIP_FOLDER);
2684
+ bool needs_trailing_slash = (isdir && dstzn[_tcslen(dstzn)-1]!='/');
2685
+ int method=DEFLATE; if (isdir || HasZipSuffix(dstzn)) method=STORE;
2686
+
2687
+ // now open whatever was our input source:
2688
+ ZRESULT openres;
2689
+ if (flags==ZIP_FILENAME) openres=open_file((const TCHAR*)src);
2690
+ else if (flags==ZIP_HANDLE) openres=open_handle((HANDLE)src,len);
2691
+ else if (flags==ZIP_MEMORY) openres=open_mem(src,len);
2692
+ else if (flags==ZIP_FOLDER) openres=open_dir();
2693
+ else return ZR_ARGS;
2694
+ if (openres!=ZR_OK) return openres;
2695
+
2696
+ // A zip "entry" consists of a local header (which includes the file name),
2697
+ // then the compressed data, and possibly an extended local header.
2698
+
2699
+ // Initialize the local header
2700
+ TZipFileInfo zfi; zfi.nxt=NULL;
2701
+ strcpy(zfi.name,"");
2702
+ #ifdef UNICODE
2703
+ WideCharToMultiByte(CP_UTF8,0,dstzn,-1,zfi.iname,MAX_PATH,0,0);
2704
+ #else
2705
+ strncpy(zfi.iname,dstzn,MAX_PATH); zfi.iname[MAX_PATH-1]=0;
2706
+ #endif
2707
+ zfi.nam=strlen(zfi.iname);
2708
+ if (needs_trailing_slash) {strcat(zfi.iname,"/"); zfi.nam++;}
2709
+ strcpy(zfi.zname,"");
2710
+ zfi.extra=NULL; zfi.ext=0; // extra header to go after this compressed data, and its length
2711
+ zfi.cextra=NULL; zfi.cext=0; // extra header to go in the central end-of-zip directory, and its length
2712
+ zfi.comment=NULL; zfi.com=0; // comment, and its length
2713
+ zfi.mark = 1;
2714
+ zfi.dosflag = 0;
2715
+ zfi.att = (ush)BINARY;
2716
+ zfi.vem = (ush)0xB17; // 0xB00 is win32 os-code. 0x17 is 23 in decimal: zip 2.3
2717
+ zfi.ver = (ush)20; // Needs PKUNZIP 2.0 to unzip it
2718
+ zfi.tim = timestamp;
2719
+ // Even though we write the header now, it will have to be rewritten, since we don't know compressed size or crc.
2720
+ zfi.crc = 0; // to be updated later
2721
+ zfi.flg = 8; // 8 means 'there is an extra header'. Assume for the moment that we need it.
2722
+ if (password!=0 && !isdir) zfi.flg=9; // and 1 means 'password-encrypted'
2723
+ zfi.lflg = zfi.flg; // to be updated later
2724
+ zfi.how = (ush)method; // to be updated later
2725
+ zfi.siz = (ulg)(method==STORE && isize>=0 ? isize+passex : 0); // to be updated later
2726
+ zfi.len = (ulg)(isize); // to be updated later
2727
+ zfi.dsk = 0;
2728
+ zfi.atx = attr;
2729
+ zfi.off = writ+ooffset; // offset within file of the start of this local record
2730
+ // stuff the 'times' structure into zfi.extra
2731
+
2732
+ // nb. apparently there's a problem with PocketPC CE(zip)->CE(unzip) fails. And removing the following block fixes it up.
2733
+ char xloc[EB_L_UT_SIZE]; zfi.extra=xloc; zfi.ext=EB_L_UT_SIZE;
2734
+ char xcen[EB_C_UT_SIZE]; zfi.cextra=xcen; zfi.cext=EB_C_UT_SIZE;
2735
+ xloc[0] = 'U';
2736
+ xloc[1] = 'T';
2737
+ xloc[2] = EB_UT_LEN(3); // length of data part of e.f.
2738
+ xloc[3] = 0;
2739
+ xloc[4] = EB_UT_FL_MTIME | EB_UT_FL_ATIME | EB_UT_FL_CTIME;
2740
+ xloc[5] = (char)(times.mtime);
2741
+ xloc[6] = (char)(times.mtime >> 8);
2742
+ xloc[7] = (char)(times.mtime >> 16);
2743
+ xloc[8] = (char)(times.mtime >> 24);
2744
+ xloc[9] = (char)(times.atime);
2745
+ xloc[10] = (char)(times.atime >> 8);
2746
+ xloc[11] = (char)(times.atime >> 16);
2747
+ xloc[12] = (char)(times.atime >> 24);
2748
+ xloc[13] = (char)(times.ctime);
2749
+ xloc[14] = (char)(times.ctime >> 8);
2750
+ xloc[15] = (char)(times.ctime >> 16);
2751
+ xloc[16] = (char)(times.ctime >> 24);
2752
+ memcpy(zfi.cextra,zfi.extra,EB_C_UT_SIZE);
2753
+ zfi.cextra[EB_LEN] = EB_UT_LEN(1);
2754
+
2755
+
2756
+ // (1) Start by writing the local header:
2757
+ int r = putlocal(&zfi,swrite,this);
2758
+ if (r!=ZE_OK) {iclose(); return ZR_WRITE;}
2759
+ writ += 4 + LOCHEAD + (unsigned int)zfi.nam + (unsigned int)zfi.ext;
2760
+ if (oerr!=ZR_OK) {iclose(); return oerr;}
2761
+
2762
+ // (1.5) if necessary, write the encryption header
2763
+ keys[0]=305419896L;
2764
+ keys[1]=591751049L;
2765
+ keys[2]=878082192L;
2766
+ for (const char *cp=password; cp!=0 && *cp!=0; cp++) update_keys(keys,*cp);
2767
+ // generate some random bytes
2768
+ #ifdef ZIP_STD
2769
+ if (!has_seeded) srand((unsigned)time(0));
2770
+ #else
2771
+ if (!has_seeded) srand(GetTickCount()^(unsigned long)GetDesktopWindow());
2772
+ #endif
2773
+ char encbuf[12]; for (int i=0; i<12; i++) encbuf[i]=(char)((rand()>>7)&0xff);
2774
+ encbuf[11] = (char)((zfi.tim>>8)&0xff);
2775
+ for (int ei=0; ei<12; ei++) encbuf[ei]=zencode(keys,encbuf[ei]);
2776
+ if (password!=0 && !isdir) {swrite(this,encbuf,12); writ+=12;}
2777
+
2778
+ //(2) Write deflated/stored file to zip file
2779
+ ZRESULT writeres=ZR_OK;
2780
+ encwriting = (password!=0 && !isdir); // an object member variable to say whether we write to disk encrypted
2781
+ if (!isdir && method==DEFLATE) writeres=ideflate(&zfi);
2782
+ else if (!isdir && method==STORE) writeres=istore();
2783
+ else if (isdir) csize=0;
2784
+ encwriting = false;
2785
+ iclose();
2786
+ writ += csize;
2787
+ if (oerr!=ZR_OK) return oerr;
2788
+ if (writeres!=ZR_OK) return ZR_WRITE;
2789
+
2790
+ // (3) Either rewrite the local header with correct information...
2791
+ bool first_header_has_size_right = (zfi.siz==csize+passex);
2792
+ zfi.crc = crc;
2793
+ zfi.siz = csize+passex;
2794
+ zfi.len = isize;
2795
+ if (ocanseek && (password==0 || isdir))
2796
+ { zfi.how = (ush)method;
2797
+ if ((zfi.flg & 1) == 0) zfi.flg &= ~8; // clear the extended local header flag
2798
+ zfi.lflg = zfi.flg;
2799
+ // rewrite the local header:
2800
+ if (!oseek(zfi.off-ooffset)) return ZR_SEEK;
2801
+ if ((r = putlocal(&zfi, swrite,this)) != ZE_OK) return ZR_WRITE;
2802
+ if (!oseek(writ)) return ZR_SEEK;
2803
+ }
2804
+ else
2805
+ { // (4) ... or put an updated header at the end
2806
+ if (zfi.how != (ush) method) return ZR_NOCHANGE;
2807
+ if (method==STORE && !first_header_has_size_right) return ZR_NOCHANGE;
2808
+ if ((r = putextended(&zfi, swrite,this)) != ZE_OK) return ZR_WRITE;
2809
+ writ += 16L;
2810
+ zfi.flg = zfi.lflg; // if flg modified by inflate, for the central index
2811
+ }
2812
+ if (oerr!=ZR_OK) return oerr;
2813
+
2814
+ // Keep a copy of the zipfileinfo, for our end-of-zip directory
2815
+ char *cextra = new char[zfi.cext]; memcpy(cextra,zfi.cextra,zfi.cext); zfi.cextra=cextra;
2816
+ TZipFileInfo *pzfi = new TZipFileInfo; memcpy(pzfi,&zfi,sizeof(zfi));
2817
+ if (zfis==NULL) zfis=pzfi;
2818
+ else {TZipFileInfo *z=zfis; while (z->nxt!=NULL) z=z->nxt; z->nxt=pzfi;}
2819
+ return ZR_OK;
2820
+ }
2821
+
2822
+ ZRESULT TZip::AddCentral()
2823
+ { // write central directory
2824
+ int numentries = 0;
2825
+ ulg pos_at_start_of_central = writ;
2826
+ //ulg tot_unc_size=0, tot_compressed_size=0;
2827
+ bool okay=true;
2828
+ for (TZipFileInfo *zfi=zfis; zfi!=NULL; )
2829
+ { if (okay)
2830
+ { int res = putcentral(zfi, swrite,this);
2831
+ if (res!=ZE_OK) okay=false;
2832
+ }
2833
+ writ += 4 + CENHEAD + (unsigned int)zfi->nam + (unsigned int)zfi->cext + (unsigned int)zfi->com;
2834
+ //tot_unc_size += zfi->len;
2835
+ //tot_compressed_size += zfi->siz;
2836
+ numentries++;
2837
+ //
2838
+ TZipFileInfo *zfinext = zfi->nxt;
2839
+ if (zfi->cextra!=0) delete[] zfi->cextra;
2840
+ delete zfi;
2841
+ zfi = zfinext;
2842
+ }
2843
+ ulg center_size = writ - pos_at_start_of_central;
2844
+ if (okay)
2845
+ { int res = putend(numentries, center_size, pos_at_start_of_central+ooffset, 0, NULL, swrite,this);
2846
+ if (res!=ZE_OK) okay=false;
2847
+ writ += 4 + ENDHEAD + 0;
2848
+ }
2849
+ if (!okay) return ZR_WRITE;
2850
+ return ZR_OK;
2851
+ }
2852
+
2853
+
2854
+
2855
+
2856
+
2857
+ ZRESULT lasterrorZ=ZR_OK;
2858
+
2859
+ unsigned int FormatZipMessageZ(ZRESULT code, char *buf,unsigned int len)
2860
+ { if (code==ZR_RECENT) code=lasterrorZ;
2861
+ const char *msg="unknown zip result code";
2862
+ switch (code)
2863
+ { case ZR_OK: msg="Success"; break;
2864
+ case ZR_NODUPH: msg="Culdn't duplicate handle"; break;
2865
+ case ZR_NOFILE: msg="Couldn't create/open file"; break;
2866
+ case ZR_NOALLOC: msg="Failed to allocate memory"; break;
2867
+ case ZR_WRITE: msg="Error writing to file"; break;
2868
+ case ZR_NOTFOUND: msg="File not found in the zipfile"; break;
2869
+ case ZR_MORE: msg="Still more data to unzip"; break;
2870
+ case ZR_CORRUPT: msg="Zipfile is corrupt or not a zipfile"; break;
2871
+ case ZR_READ: msg="Error reading file"; break;
2872
+ case ZR_ARGS: msg="Caller: faulty arguments"; break;
2873
+ case ZR_PARTIALUNZ: msg="Caller: the file had already been partially unzipped"; break;
2874
+ case ZR_NOTMMAP: msg="Caller: can only get memory of a memory zipfile"; break;
2875
+ case ZR_MEMSIZE: msg="Caller: not enough space allocated for memory zipfile"; break;
2876
+ case ZR_FAILED: msg="Caller: there was a previous error"; break;
2877
+ case ZR_ENDED: msg="Caller: additions to the zip have already been ended"; break;
2878
+ case ZR_ZMODE: msg="Caller: mixing creation and opening of zip"; break;
2879
+ case ZR_NOTINITED: msg="Zip-bug: internal initialisation not completed"; break;
2880
+ case ZR_SEEK: msg="Zip-bug: trying to seek the unseekable"; break;
2881
+ case ZR_MISSIZE: msg="Zip-bug: the anticipated size turned out wrong"; break;
2882
+ case ZR_NOCHANGE: msg="Zip-bug: tried to change mind, but not allowed"; break;
2883
+ case ZR_FLATE: msg="Zip-bug: an internal error during flation"; break;
2884
+ }
2885
+ unsigned int mlen=(unsigned int)strlen(msg);
2886
+ if (buf==0 || len==0) return mlen;
2887
+ unsigned int n=mlen; if (n+1>len) n=len-1;
2888
+ strncpy(buf,msg,n); buf[n]=0;
2889
+ return mlen;
2890
+ }
2891
+
2892
+
2893
+
2894
+ typedef struct
2895
+ { DWORD flag;
2896
+ TZip *zip;
2897
+ } TZipHandleData;
2898
+
2899
+
2900
+ HZIP CreateZipInternal(void *z,unsigned int len,DWORD flags, const char *password)
2901
+ { TZip *zip = new TZip(password);
2902
+ lasterrorZ = zip->Create(z,len,flags);
2903
+ if (lasterrorZ!=ZR_OK) {delete zip; return 0;}
2904
+ TZipHandleData *han = new TZipHandleData;
2905
+ han->flag=2; han->zip=zip; return (HZIP)han;
2906
+ }
2907
+ HZIP CreateZipHandle(HANDLE h, const char *password) {return CreateZipInternal(h,0,ZIP_HANDLE,password);}
2908
+ HZIP CreateZip(const TCHAR *fn, const char *password) {return CreateZipInternal((void*)fn,0,ZIP_FILENAME,password);}
2909
+ HZIP CreateZip(void *z,unsigned int len, const char *password) {return CreateZipInternal(z,len,ZIP_MEMORY,password);}
2910
+
2911
+
2912
+ ZRESULT ZipAddInternal(HZIP hz,const TCHAR *dstzn, void *src,unsigned int len, DWORD flags)
2913
+ { if (hz==0) {lasterrorZ=ZR_ARGS;return ZR_ARGS;}
2914
+ TZipHandleData *han = (TZipHandleData*)hz;
2915
+ if (han->flag!=2) {lasterrorZ=ZR_ZMODE;return ZR_ZMODE;}
2916
+ TZip *zip = han->zip;
2917
+ lasterrorZ = zip->Add(dstzn,src,len,flags);
2918
+ return lasterrorZ;
2919
+ }
2920
+ ZRESULT ZipAdd(HZIP hz,const TCHAR *dstzn, const TCHAR *fn) {return ZipAddInternal(hz,dstzn,(void*)fn,0,ZIP_FILENAME);}
2921
+ ZRESULT ZipAdd(HZIP hz,const TCHAR *dstzn, void *src,unsigned int len) {return ZipAddInternal(hz,dstzn,src,len,ZIP_MEMORY);}
2922
+ ZRESULT ZipAddHandle(HZIP hz,const TCHAR *dstzn, HANDLE h) {return ZipAddInternal(hz,dstzn,h,0,ZIP_HANDLE);}
2923
+ ZRESULT ZipAddHandle(HZIP hz,const TCHAR *dstzn, HANDLE h, unsigned int len) {return ZipAddInternal(hz,dstzn,h,len,ZIP_HANDLE);}
2924
+ ZRESULT ZipAddFolder(HZIP hz,const TCHAR *dstzn, const TCHAR *fn) {return ZipAddInternal(hz,dstzn,(void*)fn,0,ZIP_FOLDER);}
2925
+
2926
+
2927
+
2928
+ ZRESULT ZipGetMemory(HZIP hz, void **buf, unsigned long *len)
2929
+ { if (hz==0) {if (buf!=0) *buf=0; if (len!=0) *len=0; lasterrorZ=ZR_ARGS;return ZR_ARGS;}
2930
+ TZipHandleData *han = (TZipHandleData*)hz;
2931
+ if (han->flag!=2) {lasterrorZ=ZR_ZMODE;return ZR_ZMODE;}
2932
+ TZip *zip = han->zip;
2933
+ lasterrorZ = zip->GetMemory(buf,len);
2934
+ return lasterrorZ;
2935
+ }
2936
+
2937
+ ZRESULT CloseZipZ(HZIP hz)
2938
+ { if (hz==0) {lasterrorZ=ZR_ARGS;return ZR_ARGS;}
2939
+ TZipHandleData *han = (TZipHandleData*)hz;
2940
+ if (han->flag!=2) {lasterrorZ=ZR_ZMODE;return ZR_ZMODE;}
2941
+ TZip *zip = han->zip;
2942
+ lasterrorZ = zip->Close();
2943
+ delete zip;
2944
+ delete han;
2945
+ return lasterrorZ;
2946
+ }
2947
+
2948
+ bool IsZipHandleZ(HZIP hz)
2949
+ { if (hz==0) return false;
2950
+ TZipHandleData *han = (TZipHandleData*)hz;
2951
+ return (han->flag==2);
2952
+ }
2953
+