libarchive-static 1.0.5 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (296) hide show
  1. checksums.yaml +5 -5
  2. data/ext/extconf.rb +2 -9
  3. data/ext/libarchive-0.1.1/ext/archive_read_support_compression.c +6 -6
  4. data/ext/libarchive-0.1.1/ext/archive_read_support_compression.o +0 -0
  5. data/ext/libarchive-0.1.1/ext/archive_read_support_format.o +0 -0
  6. data/ext/libarchive-0.1.1/ext/archive_write_open_rb_str.c +1 -1
  7. data/ext/libarchive-0.1.1/ext/archive_write_open_rb_str.o +0 -0
  8. data/ext/libarchive-0.1.1/ext/archive_write_set_compression.c +5 -5
  9. data/ext/libarchive-0.1.1/ext/archive_write_set_compression.o +0 -0
  10. data/ext/libarchive-0.1.1/ext/config.h +23 -0
  11. data/ext/libarchive-0.1.1/ext/config.log +230 -0
  12. data/ext/libarchive-0.1.1/ext/config.status +671 -0
  13. data/ext/libarchive-0.1.1/ext/libarchive.c +1 -1
  14. data/ext/libarchive-0.1.1/ext/libarchive.o +0 -0
  15. data/ext/libarchive-0.1.1/ext/libarchive_archive.c +7 -7
  16. data/ext/libarchive-0.1.1/ext/libarchive_archive.o +0 -0
  17. data/ext/libarchive-0.1.1/ext/libarchive_entry.c +6 -0
  18. data/ext/libarchive-0.1.1/ext/libarchive_entry.o +0 -0
  19. data/ext/libarchive-0.1.1/ext/libarchive_internal.h +0 -1
  20. data/ext/libarchive-0.1.1/ext/libarchive_reader.c +6 -4
  21. data/ext/libarchive-0.1.1/ext/libarchive_reader.o +0 -0
  22. data/ext/libarchive-0.1.1/ext/libarchive_ruby.so +0 -0
  23. data/ext/libarchive-0.1.1/ext/libarchive_win32.h +1 -1
  24. data/ext/libarchive-0.1.1/ext/libarchive_writer.c +2 -2
  25. data/ext/libarchive-0.1.1/ext/libarchive_writer.o +0 -0
  26. data/ext/libarchive-3.6.2/Makefile.in +16892 -0
  27. data/ext/libarchive-3.6.2/build/autoconf/ax_append_compile_flags.m4 +67 -0
  28. data/ext/libarchive-3.6.2/build/autoconf/ax_append_flag.m4 +71 -0
  29. data/ext/libarchive-3.6.2/build/autoconf/ax_check_compile_flag.m4 +74 -0
  30. data/ext/libarchive-3.6.2/build/autoconf/ax_require_defined.m4 +37 -0
  31. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/build/autoconf/check_stdcall_func.m4 +0 -0
  32. data/ext/libarchive-3.6.2/build/autoconf/compile +348 -0
  33. data/ext/libarchive-3.6.2/build/autoconf/config.guess +1754 -0
  34. data/ext/libarchive-3.6.2/build/autoconf/config.rpath +696 -0
  35. data/ext/libarchive-3.6.2/build/autoconf/config.sub +1890 -0
  36. data/ext/libarchive-3.6.2/build/autoconf/depcomp +791 -0
  37. data/ext/libarchive-3.6.2/build/autoconf/iconv.m4 +271 -0
  38. data/ext/libarchive-3.6.2/build/autoconf/install-sh +541 -0
  39. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/build/autoconf/la_uid_t.m4 +0 -0
  40. data/ext/libarchive-3.6.2/build/autoconf/lib-ld.m4 +109 -0
  41. data/ext/libarchive-3.6.2/build/autoconf/lib-link.m4 +777 -0
  42. data/ext/libarchive-3.6.2/build/autoconf/lib-prefix.m4 +224 -0
  43. data/ext/libarchive-3.6.2/build/autoconf/ltmain.sh +11251 -0
  44. data/ext/libarchive-3.6.2/build/autoconf/m4_ax_compile_check_sizeof.m4 +115 -0
  45. data/ext/libarchive-3.6.2/build/autoconf/missing +215 -0
  46. data/ext/libarchive-3.6.2/build/autoconf/test-driver +153 -0
  47. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/build/pkgconfig/libarchive.pc.in +4 -1
  48. data/ext/libarchive-3.6.2/config.h.in +1504 -0
  49. data/ext/libarchive-3.6.2/configure +25558 -0
  50. data/ext/libarchive-3.6.2/libarchive/archive.h +1212 -0
  51. data/ext/libarchive-3.6.2/libarchive/archive_acl.c +2097 -0
  52. data/ext/libarchive-3.6.2/libarchive/archive_acl_private.h +83 -0
  53. data/ext/libarchive-3.6.2/libarchive/archive_blake2.h +197 -0
  54. data/ext/libarchive-3.6.2/libarchive/archive_blake2_impl.h +161 -0
  55. data/ext/libarchive-3.6.2/libarchive/archive_blake2s_ref.c +369 -0
  56. data/ext/libarchive-3.6.2/libarchive/archive_blake2sp_ref.c +361 -0
  57. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_check_magic.c +63 -22
  58. data/ext/libarchive-3.6.2/libarchive/archive_cmdline.c +227 -0
  59. data/ext/libarchive-3.6.2/libarchive/archive_cmdline_private.h +47 -0
  60. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_crc32.h +17 -0
  61. data/ext/libarchive-3.6.2/libarchive/archive_cryptor.c +534 -0
  62. data/ext/libarchive-3.6.2/libarchive/archive_cryptor_private.h +188 -0
  63. data/ext/libarchive-3.6.2/libarchive/archive_digest.c +1505 -0
  64. data/ext/libarchive-3.6.2/libarchive/archive_digest_private.h +416 -0
  65. data/ext/libarchive-3.6.2/libarchive/archive_disk_acl_darwin.c +559 -0
  66. data/ext/libarchive-3.6.2/libarchive/archive_disk_acl_freebsd.c +712 -0
  67. data/ext/libarchive-3.6.2/libarchive/archive_disk_acl_linux.c +760 -0
  68. data/ext/libarchive-3.6.2/libarchive/archive_disk_acl_sunos.c +824 -0
  69. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_endian.h +48 -15
  70. data/ext/libarchive-3.6.2/libarchive/archive_entry.c +2149 -0
  71. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry.h +305 -106
  72. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_copy_bhfi.c +5 -4
  73. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_copy_stat.c +9 -3
  74. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_link_resolver.c +104 -62
  75. data/ext/libarchive-3.6.2/libarchive/archive_entry_locale.h +92 -0
  76. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_private.h +65 -49
  77. data/ext/libarchive-3.6.2/libarchive/archive_entry_sparse.c +156 -0
  78. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_stat.c +6 -6
  79. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_strmode.c +1 -1
  80. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_xattr.c +4 -6
  81. data/ext/libarchive-3.6.2/libarchive/archive_getdate.c +1165 -0
  82. data/ext/libarchive-3.6.2/libarchive/archive_getdate.h +39 -0
  83. data/ext/libarchive-3.6.2/libarchive/archive_hmac.c +334 -0
  84. data/ext/libarchive-3.6.2/libarchive/archive_hmac_private.h +117 -0
  85. data/ext/libarchive-3.6.2/libarchive/archive_match.c +1875 -0
  86. data/ext/libarchive-3.6.2/libarchive/archive_openssl_evp_private.h +53 -0
  87. data/ext/libarchive-3.6.2/libarchive/archive_openssl_hmac_private.h +54 -0
  88. data/ext/libarchive-3.6.2/libarchive/archive_options.c +218 -0
  89. data/ext/libarchive-3.6.2/libarchive/archive_options_private.h +51 -0
  90. data/ext/libarchive-3.6.2/libarchive/archive_pack_dev.c +337 -0
  91. data/ext/libarchive-3.6.2/libarchive/archive_pack_dev.h +49 -0
  92. data/ext/libarchive-3.6.2/libarchive/archive_pathmatch.c +463 -0
  93. data/ext/libarchive-3.6.2/libarchive/archive_pathmatch.h +52 -0
  94. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_platform.h +77 -9
  95. data/ext/libarchive-3.6.2/libarchive/archive_platform_acl.h +55 -0
  96. data/ext/libarchive-3.6.2/libarchive/archive_platform_xattr.h +47 -0
  97. data/ext/libarchive-3.6.2/libarchive/archive_ppmd7.c +1168 -0
  98. data/ext/libarchive-3.6.2/libarchive/archive_ppmd7_private.h +119 -0
  99. data/ext/libarchive-3.6.2/libarchive/archive_ppmd8.c +1287 -0
  100. data/ext/libarchive-3.6.2/libarchive/archive_ppmd8_private.h +148 -0
  101. data/ext/libarchive-3.6.2/libarchive/archive_ppmd_private.h +151 -0
  102. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_private.h +74 -18
  103. data/ext/libarchive-3.6.2/libarchive/archive_random.c +272 -0
  104. data/ext/libarchive-3.6.2/libarchive/archive_random_private.h +36 -0
  105. data/ext/libarchive-3.6.2/libarchive/archive_rb.c +709 -0
  106. data/ext/libarchive-3.6.2/libarchive/archive_rb.h +113 -0
  107. data/ext/libarchive-3.6.2/libarchive/archive_read.c +1756 -0
  108. data/ext/libarchive-3.6.2/libarchive/archive_read_add_passphrase.c +190 -0
  109. data/ext/libarchive-3.6.2/libarchive/archive_read_append_filter.c +204 -0
  110. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_data_into_fd.c +64 -18
  111. data/ext/libarchive-3.6.2/libarchive/archive_read_disk_entry_from_file.c +1086 -0
  112. data/ext/libarchive-3.6.2/libarchive/archive_read_disk_posix.c +2732 -0
  113. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_disk_private.h +40 -4
  114. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_disk_set_standard_lookup.c +21 -11
  115. data/ext/libarchive-3.6.2/libarchive/archive_read_disk_windows.c +2479 -0
  116. data/ext/libarchive-3.6.2/libarchive/archive_read_extract.c +60 -0
  117. data/ext/{libarchive-2.8.4/libarchive/archive_read_extract.c → libarchive-3.6.2/libarchive/archive_read_extract2.c} +34 -61
  118. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_open_fd.c +70 -49
  119. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_open_file.c +38 -23
  120. data/ext/libarchive-3.6.2/libarchive/archive_read_open_filename.c +586 -0
  121. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_open_memory.c +58 -28
  122. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_private.h +127 -59
  123. data/ext/libarchive-3.6.2/libarchive/archive_read_set_format.c +117 -0
  124. data/ext/libarchive-3.6.2/libarchive/archive_read_set_options.c +133 -0
  125. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_all.c → libarchive-3.6.2/libarchive/archive_read_support_filter_all.c} +35 -10
  126. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_by_code.c +83 -0
  127. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_bzip2.c → libarchive-3.6.2/libarchive/archive_read_support_filter_bzip2.c} +38 -26
  128. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_compress.c → libarchive-3.6.2/libarchive/archive_read_support_filter_compress.c} +52 -44
  129. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_grzip.c +112 -0
  130. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_gzip.c → libarchive-3.6.2/libarchive/archive_read_support_filter_gzip.c} +108 -37
  131. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_lrzip.c +122 -0
  132. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_lz4.c +742 -0
  133. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_lzop.c +499 -0
  134. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_none.c → libarchive-3.6.2/libarchive/archive_read_support_filter_none.c} +15 -3
  135. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_program.c → libarchive-3.6.2/libarchive/archive_read_support_filter_program.c} +114 -77
  136. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_rpm.c → libarchive-3.6.2/libarchive/archive_read_support_filter_rpm.c} +31 -31
  137. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_uu.c → libarchive-3.6.2/libarchive/archive_read_support_filter_uu.c} +141 -85
  138. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_xz.c → libarchive-3.6.2/libarchive/archive_read_support_filter_xz.c} +369 -284
  139. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_zstd.c +297 -0
  140. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_7zip.c +3900 -0
  141. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_all.c +89 -0
  142. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_ar.c +126 -72
  143. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_by_code.c +92 -0
  144. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_cab.c +3228 -0
  145. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_cpio.c +1104 -0
  146. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_empty.c +14 -11
  147. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_iso9660.c +990 -541
  148. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_lha.c +2916 -0
  149. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_mtree.c +2150 -0
  150. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_rar.c +3797 -0
  151. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_rar5.c +4251 -0
  152. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_raw.c +38 -31
  153. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_tar.c +1157 -629
  154. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_warc.c +848 -0
  155. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_xar.c +439 -258
  156. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_zip.c +4270 -0
  157. data/ext/libarchive-3.6.2/libarchive/archive_string.c +4240 -0
  158. data/ext/libarchive-3.6.2/libarchive/archive_string.h +243 -0
  159. data/ext/libarchive-3.6.2/libarchive/archive_string_composition.h +2292 -0
  160. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_string_sprintf.c +44 -16
  161. data/ext/libarchive-3.6.2/libarchive/archive_util.c +655 -0
  162. data/ext/libarchive-3.6.2/libarchive/archive_version_details.c +151 -0
  163. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_virtual.c +85 -16
  164. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_windows.c +214 -541
  165. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_windows.h +74 -106
  166. data/ext/libarchive-3.6.2/libarchive/archive_write.c +828 -0
  167. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter.c +72 -0
  168. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_b64encode.c +304 -0
  169. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_by_name.c +77 -0
  170. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_bzip2.c +401 -0
  171. data/ext/{libarchive-2.8.4/libarchive/archive_write_set_compression_compress.c → libarchive-3.6.2/libarchive/archive_write_add_filter_compress.c} +86 -131
  172. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_grzip.c +135 -0
  173. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_gzip.c +442 -0
  174. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_lrzip.c +197 -0
  175. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_lz4.c +700 -0
  176. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_lzop.c +478 -0
  177. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_format_all.c → libarchive-3.6.2/libarchive/archive_write_add_filter_none.c} +11 -11
  178. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_program.c +391 -0
  179. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_uuencode.c +295 -0
  180. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_xz.c +545 -0
  181. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_zstd.c +418 -0
  182. data/ext/libarchive-3.6.2/libarchive/archive_write_disk_posix.c +4711 -0
  183. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_disk_private.h +9 -2
  184. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_disk_set_standard_lookup.c +30 -29
  185. data/ext/libarchive-3.6.2/libarchive/archive_write_disk_windows.c +2842 -0
  186. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_open_fd.c +15 -10
  187. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_open_file.c +15 -9
  188. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_open_filename.c +128 -20
  189. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_open_memory.c +7 -18
  190. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_private.h +72 -29
  191. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format.c +56 -3
  192. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_7zip.c +2322 -0
  193. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_ar.c +54 -34
  194. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_by_name.c +20 -2
  195. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_cpio.c +11 -0
  196. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_cpio_binary.c +610 -0
  197. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_cpio_newc.c +457 -0
  198. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_cpio_odc.c +500 -0
  199. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_filter_by_ext.c +142 -0
  200. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_gnutar.c +755 -0
  201. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_iso9660.c +8165 -0
  202. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_mtree.c +2217 -0
  203. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_pax.c +1049 -387
  204. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_private.h +42 -0
  205. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_raw.c +125 -0
  206. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_shar.c +62 -47
  207. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_ustar.c +279 -108
  208. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_v7tar.c +638 -0
  209. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_warc.c +453 -0
  210. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_xar.c +3259 -0
  211. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_zip.c +1704 -0
  212. data/ext/libarchive-3.6.2/libarchive/archive_write_set_options.c +130 -0
  213. data/ext/libarchive-3.6.2/libarchive/archive_write_set_passphrase.c +95 -0
  214. data/ext/libarchive-3.6.2/libarchive/archive_xxhash.h +48 -0
  215. data/ext/libarchive-3.6.2/libarchive/config_freebsd.h +271 -0
  216. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/filter_fork.h +10 -5
  217. data/ext/{libarchive-2.8.4/libarchive/filter_fork.c → libarchive-3.6.2/libarchive/filter_fork_posix.c} +98 -19
  218. data/ext/libarchive-3.6.2/libarchive/filter_fork_windows.c +236 -0
  219. data/ext/libarchive-3.6.2/libarchive/xxhash.c +525 -0
  220. data/ext/libarchive-static-makefile +144 -80
  221. data/ext/libarchive-static-wrapper-makefile +1 -1
  222. data/ext/zlib-1.2.13/Makefile.in +404 -0
  223. data/ext/{zlib-1.2.5 → zlib-1.2.13}/adler32.c +51 -34
  224. data/ext/{zlib-1.2.5 → zlib-1.2.13}/compress.c +27 -21
  225. data/ext/zlib-1.2.13/configure +922 -0
  226. data/ext/zlib-1.2.13/crc32.c +1125 -0
  227. data/ext/zlib-1.2.13/crc32.h +9446 -0
  228. data/ext/{zlib-1.2.5 → zlib-1.2.13}/deflate.c +842 -459
  229. data/ext/{zlib-1.2.5 → zlib-1.2.13}/deflate.h +37 -33
  230. data/ext/{zlib-1.2.5 → zlib-1.2.13}/gzclose.c +0 -0
  231. data/ext/{zlib-1.2.5 → zlib-1.2.13}/gzguts.h +103 -16
  232. data/ext/{zlib-1.2.5 → zlib-1.2.13}/gzlib.c +155 -53
  233. data/ext/zlib-1.2.13/gzread.c +650 -0
  234. data/ext/zlib-1.2.13/gzwrite.c +677 -0
  235. data/ext/{zlib-1.2.5 → zlib-1.2.13}/infback.c +24 -12
  236. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inffast.c +49 -66
  237. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inffast.h +0 -0
  238. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inffixed.h +3 -3
  239. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inflate.c +209 -94
  240. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inflate.h +9 -5
  241. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inftrees.c +24 -50
  242. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inftrees.h +1 -1
  243. data/ext/{zlib-1.2.5 → zlib-1.2.13}/trees.c +135 -198
  244. data/ext/{zlib-1.2.5 → zlib-1.2.13}/trees.h +0 -0
  245. data/ext/zlib-1.2.13/uncompr.c +93 -0
  246. data/ext/{zlib-1.2.5 → zlib-1.2.13}/zconf.h +182 -63
  247. data/ext/{zlib-1.2.5 → zlib-1.2.13}/zlib.h +617 -295
  248. data/ext/{zlib-1.2.5 → zlib-1.2.13}/zutil.c +50 -41
  249. data/ext/{zlib-1.2.5 → zlib-1.2.13}/zutil.h +83 -82
  250. metadata +244 -137
  251. data/ext/libarchive-0.1.1/libarchive.c +0 -1762
  252. data/ext/libarchive-2.8.4/Makefile.in +0 -7076
  253. data/ext/libarchive-2.8.4/build/autoconf/compile +0 -143
  254. data/ext/libarchive-2.8.4/build/autoconf/config.guess +0 -1502
  255. data/ext/libarchive-2.8.4/build/autoconf/config.sub +0 -1708
  256. data/ext/libarchive-2.8.4/build/autoconf/depcomp +0 -630
  257. data/ext/libarchive-2.8.4/build/autoconf/install-sh +0 -291
  258. data/ext/libarchive-2.8.4/build/autoconf/ltmain.sh +0 -8406
  259. data/ext/libarchive-2.8.4/build/autoconf/missing +0 -376
  260. data/ext/libarchive-2.8.4/config.h.in +0 -772
  261. data/ext/libarchive-2.8.4/configure +0 -17916
  262. data/ext/libarchive-2.8.4/libarchive/archive.h +0 -741
  263. data/ext/libarchive-2.8.4/libarchive/archive_entry.c +0 -2202
  264. data/ext/libarchive-2.8.4/libarchive/archive_hash.h +0 -281
  265. data/ext/libarchive-2.8.4/libarchive/archive_read.c +0 -1249
  266. data/ext/libarchive-2.8.4/libarchive/archive_read_disk.c +0 -198
  267. data/ext/libarchive-2.8.4/libarchive/archive_read_disk_entry_from_file.c +0 -570
  268. data/ext/libarchive-2.8.4/libarchive/archive_read_open_filename.c +0 -272
  269. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_cpio.c +0 -777
  270. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_mtree.c +0 -1304
  271. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_zip.c +0 -903
  272. data/ext/libarchive-2.8.4/libarchive/archive_string.c +0 -453
  273. data/ext/libarchive-2.8.4/libarchive/archive_string.h +0 -148
  274. data/ext/libarchive-2.8.4/libarchive/archive_util.c +0 -391
  275. data/ext/libarchive-2.8.4/libarchive/archive_write.c +0 -466
  276. data/ext/libarchive-2.8.4/libarchive/archive_write_disk.c +0 -2628
  277. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_bzip2.c +0 -408
  278. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_gzip.c +0 -477
  279. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_none.c +0 -257
  280. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_program.c +0 -347
  281. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_xz.c +0 -438
  282. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_cpio.c +0 -344
  283. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_cpio_newc.c +0 -295
  284. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_mtree.c +0 -1050
  285. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_zip.c +0 -667
  286. data/ext/libarchive-2.8.4/libarchive/config_freebsd.h +0 -154
  287. data/ext/libarchive-2.8.4/libarchive/filter_fork_windows.c +0 -113
  288. data/ext/zlib-1.2.5/Makefile.in +0 -257
  289. data/ext/zlib-1.2.5/configure +0 -596
  290. data/ext/zlib-1.2.5/crc32.c +0 -442
  291. data/ext/zlib-1.2.5/crc32.h +0 -441
  292. data/ext/zlib-1.2.5/example.c +0 -565
  293. data/ext/zlib-1.2.5/gzread.c +0 -653
  294. data/ext/zlib-1.2.5/gzwrite.c +0 -531
  295. data/ext/zlib-1.2.5/minigzip.c +0 -440
  296. data/ext/zlib-1.2.5/uncompr.c +0 -59
@@ -0,0 +1,442 @@
1
+ /*-
2
+ * Copyright (c) 2003-2007 Tim Kientzle
3
+ * All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without
6
+ * modification, are permitted provided that the following conditions
7
+ * are met:
8
+ * 1. Redistributions of source code must retain the above copyright
9
+ * notice, this list of conditions and the following disclaimer.
10
+ * 2. Redistributions in binary form must reproduce the above copyright
11
+ * notice, this list of conditions and the following disclaimer in the
12
+ * documentation and/or other materials provided with the distribution.
13
+ *
14
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ */
25
+
26
+ #include "archive_platform.h"
27
+
28
+ __FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_compression_gzip.c 201081 2009-12-28 02:04:42Z kientzle $");
29
+
30
+ #ifdef HAVE_ERRNO_H
31
+ #include <errno.h>
32
+ #endif
33
+ #ifdef HAVE_STDLIB_H
34
+ #include <stdlib.h>
35
+ #endif
36
+ #ifdef HAVE_STRING_H
37
+ #include <string.h>
38
+ #endif
39
+ #include <time.h>
40
+ #ifdef HAVE_ZLIB_H
41
+ #include <zlib.h>
42
+ #endif
43
+
44
+ #include "archive.h"
45
+ #include "archive_private.h"
46
+ #include "archive_string.h"
47
+ #include "archive_write_private.h"
48
+
49
+ #if ARCHIVE_VERSION_NUMBER < 4000000
50
+ int
51
+ archive_write_set_compression_gzip(struct archive *a)
52
+ {
53
+ __archive_write_filters_free(a);
54
+ return (archive_write_add_filter_gzip(a));
55
+ }
56
+ #endif
57
+
58
+ /* Don't compile this if we don't have zlib. */
59
+
60
+ struct private_data {
61
+ int compression_level;
62
+ int timestamp;
63
+ #ifdef HAVE_ZLIB_H
64
+ z_stream stream;
65
+ int64_t total_in;
66
+ unsigned char *compressed;
67
+ size_t compressed_buffer_size;
68
+ unsigned long crc;
69
+ #else
70
+ struct archive_write_program_data *pdata;
71
+ #endif
72
+ };
73
+
74
+ /*
75
+ * Yuck. zlib.h is not const-correct, so I need this one bit
76
+ * of ugly hackery to convert a const * pointer to a non-const pointer.
77
+ */
78
+ #define SET_NEXT_IN(st,src) \
79
+ (st)->stream.next_in = (Bytef *)(uintptr_t)(const void *)(src)
80
+
81
+ static int archive_compressor_gzip_options(struct archive_write_filter *,
82
+ const char *, const char *);
83
+ static int archive_compressor_gzip_open(struct archive_write_filter *);
84
+ static int archive_compressor_gzip_write(struct archive_write_filter *,
85
+ const void *, size_t);
86
+ static int archive_compressor_gzip_close(struct archive_write_filter *);
87
+ static int archive_compressor_gzip_free(struct archive_write_filter *);
88
+ #ifdef HAVE_ZLIB_H
89
+ static int drive_compressor(struct archive_write_filter *,
90
+ struct private_data *, int finishing);
91
+ #endif
92
+
93
+
94
+ /*
95
+ * Add a gzip compression filter to this write handle.
96
+ */
97
+ int
98
+ archive_write_add_filter_gzip(struct archive *_a)
99
+ {
100
+ struct archive_write *a = (struct archive_write *)_a;
101
+ struct archive_write_filter *f = __archive_write_allocate_filter(_a);
102
+ struct private_data *data;
103
+ archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
104
+ ARCHIVE_STATE_NEW, "archive_write_add_filter_gzip");
105
+
106
+ data = calloc(1, sizeof(*data));
107
+ if (data == NULL) {
108
+ archive_set_error(&a->archive, ENOMEM, "Out of memory");
109
+ return (ARCHIVE_FATAL);
110
+ }
111
+ f->data = data;
112
+ f->open = &archive_compressor_gzip_open;
113
+ f->options = &archive_compressor_gzip_options;
114
+ f->close = &archive_compressor_gzip_close;
115
+ f->free = &archive_compressor_gzip_free;
116
+ f->code = ARCHIVE_FILTER_GZIP;
117
+ f->name = "gzip";
118
+ #ifdef HAVE_ZLIB_H
119
+ data->compression_level = Z_DEFAULT_COMPRESSION;
120
+ return (ARCHIVE_OK);
121
+ #else
122
+ data->pdata = __archive_write_program_allocate("gzip");
123
+ if (data->pdata == NULL) {
124
+ free(data);
125
+ archive_set_error(&a->archive, ENOMEM, "Out of memory");
126
+ return (ARCHIVE_FATAL);
127
+ }
128
+ data->compression_level = 0;
129
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
130
+ "Using external gzip program");
131
+ return (ARCHIVE_WARN);
132
+ #endif
133
+ }
134
+
135
+ static int
136
+ archive_compressor_gzip_free(struct archive_write_filter *f)
137
+ {
138
+ struct private_data *data = (struct private_data *)f->data;
139
+
140
+ #ifdef HAVE_ZLIB_H
141
+ free(data->compressed);
142
+ #else
143
+ __archive_write_program_free(data->pdata);
144
+ #endif
145
+ free(data);
146
+ f->data = NULL;
147
+ return (ARCHIVE_OK);
148
+ }
149
+
150
+ /*
151
+ * Set write options.
152
+ */
153
+ static int
154
+ archive_compressor_gzip_options(struct archive_write_filter *f, const char *key,
155
+ const char *value)
156
+ {
157
+ struct private_data *data = (struct private_data *)f->data;
158
+
159
+ if (strcmp(key, "compression-level") == 0) {
160
+ if (value == NULL || !(value[0] >= '0' && value[0] <= '9') ||
161
+ value[1] != '\0')
162
+ return (ARCHIVE_WARN);
163
+ data->compression_level = value[0] - '0';
164
+ return (ARCHIVE_OK);
165
+ }
166
+ if (strcmp(key, "timestamp") == 0) {
167
+ data->timestamp = (value == NULL)?-1:1;
168
+ return (ARCHIVE_OK);
169
+ }
170
+
171
+ /* Note: The "warn" return is just to inform the options
172
+ * supervisor that we didn't handle it. It will generate
173
+ * a suitable error if no one used this option. */
174
+ return (ARCHIVE_WARN);
175
+ }
176
+
177
+ #ifdef HAVE_ZLIB_H
178
+ /*
179
+ * Setup callback.
180
+ */
181
+ static int
182
+ archive_compressor_gzip_open(struct archive_write_filter *f)
183
+ {
184
+ struct private_data *data = (struct private_data *)f->data;
185
+ int ret;
186
+
187
+ if (data->compressed == NULL) {
188
+ size_t bs = 65536, bpb;
189
+ if (f->archive->magic == ARCHIVE_WRITE_MAGIC) {
190
+ /* Buffer size should be a multiple number of
191
+ * the of bytes per block for performance. */
192
+ bpb = archive_write_get_bytes_per_block(f->archive);
193
+ if (bpb > bs)
194
+ bs = bpb;
195
+ else if (bpb != 0)
196
+ bs -= bs % bpb;
197
+ }
198
+ data->compressed_buffer_size = bs;
199
+ data->compressed
200
+ = (unsigned char *)malloc(data->compressed_buffer_size);
201
+ if (data->compressed == NULL) {
202
+ archive_set_error(f->archive, ENOMEM,
203
+ "Can't allocate data for compression buffer");
204
+ return (ARCHIVE_FATAL);
205
+ }
206
+ }
207
+
208
+ data->crc = crc32(0L, NULL, 0);
209
+ data->stream.next_out = data->compressed;
210
+ data->stream.avail_out = (uInt)data->compressed_buffer_size;
211
+
212
+ /* Prime output buffer with a gzip header. */
213
+ data->compressed[0] = 0x1f; /* GZip signature bytes */
214
+ data->compressed[1] = 0x8b;
215
+ data->compressed[2] = 0x08; /* "Deflate" compression */
216
+ data->compressed[3] = 0; /* No options */
217
+ if (data->timestamp >= 0) {
218
+ time_t t = time(NULL);
219
+ data->compressed[4] = (uint8_t)(t)&0xff; /* Timestamp */
220
+ data->compressed[5] = (uint8_t)(t>>8)&0xff;
221
+ data->compressed[6] = (uint8_t)(t>>16)&0xff;
222
+ data->compressed[7] = (uint8_t)(t>>24)&0xff;
223
+ } else
224
+ memset(&data->compressed[4], 0, 4);
225
+ if (data->compression_level == 9)
226
+ data->compressed[8] = 2;
227
+ else if(data->compression_level == 1)
228
+ data->compressed[8] = 4;
229
+ else
230
+ data->compressed[8] = 0;
231
+ data->compressed[9] = 3; /* OS=Unix */
232
+ data->stream.next_out += 10;
233
+ data->stream.avail_out -= 10;
234
+
235
+ f->write = archive_compressor_gzip_write;
236
+
237
+ /* Initialize compression library. */
238
+ ret = deflateInit2(&(data->stream),
239
+ data->compression_level,
240
+ Z_DEFLATED,
241
+ -15 /* < 0 to suppress zlib header */,
242
+ 8,
243
+ Z_DEFAULT_STRATEGY);
244
+
245
+ if (ret == Z_OK) {
246
+ f->data = data;
247
+ return (ARCHIVE_OK);
248
+ }
249
+
250
+ /* Library setup failed: clean up. */
251
+ archive_set_error(f->archive, ARCHIVE_ERRNO_MISC, "Internal error "
252
+ "initializing compression library");
253
+
254
+ /* Override the error message if we know what really went wrong. */
255
+ switch (ret) {
256
+ case Z_STREAM_ERROR:
257
+ archive_set_error(f->archive, ARCHIVE_ERRNO_MISC,
258
+ "Internal error initializing "
259
+ "compression library: invalid setup parameter");
260
+ break;
261
+ case Z_MEM_ERROR:
262
+ archive_set_error(f->archive, ENOMEM,
263
+ "Internal error initializing compression library");
264
+ break;
265
+ case Z_VERSION_ERROR:
266
+ archive_set_error(f->archive, ARCHIVE_ERRNO_MISC,
267
+ "Internal error initializing "
268
+ "compression library: invalid library version");
269
+ break;
270
+ }
271
+
272
+ return (ARCHIVE_FATAL);
273
+ }
274
+
275
+ /*
276
+ * Write data to the compressed stream.
277
+ */
278
+ static int
279
+ archive_compressor_gzip_write(struct archive_write_filter *f, const void *buff,
280
+ size_t length)
281
+ {
282
+ struct private_data *data = (struct private_data *)f->data;
283
+ int ret;
284
+
285
+ /* Update statistics */
286
+ data->crc = crc32(data->crc, (const Bytef *)buff, (uInt)length);
287
+ data->total_in += length;
288
+
289
+ /* Compress input data to output buffer */
290
+ SET_NEXT_IN(data, buff);
291
+ data->stream.avail_in = (uInt)length;
292
+ if ((ret = drive_compressor(f, data, 0)) != ARCHIVE_OK)
293
+ return (ret);
294
+
295
+ return (ARCHIVE_OK);
296
+ }
297
+
298
+ /*
299
+ * Finish the compression...
300
+ */
301
+ static int
302
+ archive_compressor_gzip_close(struct archive_write_filter *f)
303
+ {
304
+ unsigned char trailer[8];
305
+ struct private_data *data = (struct private_data *)f->data;
306
+ int ret;
307
+
308
+ /* Finish compression cycle */
309
+ ret = drive_compressor(f, data, 1);
310
+ if (ret == ARCHIVE_OK) {
311
+ /* Write the last compressed data. */
312
+ ret = __archive_write_filter(f->next_filter,
313
+ data->compressed,
314
+ data->compressed_buffer_size - data->stream.avail_out);
315
+ }
316
+ if (ret == ARCHIVE_OK) {
317
+ /* Build and write out 8-byte trailer. */
318
+ trailer[0] = (uint8_t)(data->crc)&0xff;
319
+ trailer[1] = (uint8_t)(data->crc >> 8)&0xff;
320
+ trailer[2] = (uint8_t)(data->crc >> 16)&0xff;
321
+ trailer[3] = (uint8_t)(data->crc >> 24)&0xff;
322
+ trailer[4] = (uint8_t)(data->total_in)&0xff;
323
+ trailer[5] = (uint8_t)(data->total_in >> 8)&0xff;
324
+ trailer[6] = (uint8_t)(data->total_in >> 16)&0xff;
325
+ trailer[7] = (uint8_t)(data->total_in >> 24)&0xff;
326
+ ret = __archive_write_filter(f->next_filter, trailer, 8);
327
+ }
328
+
329
+ switch (deflateEnd(&(data->stream))) {
330
+ case Z_OK:
331
+ break;
332
+ default:
333
+ archive_set_error(f->archive, ARCHIVE_ERRNO_MISC,
334
+ "Failed to clean up compressor");
335
+ ret = ARCHIVE_FATAL;
336
+ }
337
+ return ret;
338
+ }
339
+
340
+ /*
341
+ * Utility function to push input data through compressor,
342
+ * writing full output blocks as necessary.
343
+ *
344
+ * Note that this handles both the regular write case (finishing ==
345
+ * false) and the end-of-archive case (finishing == true).
346
+ */
347
+ static int
348
+ drive_compressor(struct archive_write_filter *f,
349
+ struct private_data *data, int finishing)
350
+ {
351
+ int ret;
352
+
353
+ for (;;) {
354
+ if (data->stream.avail_out == 0) {
355
+ ret = __archive_write_filter(f->next_filter,
356
+ data->compressed,
357
+ data->compressed_buffer_size);
358
+ if (ret != ARCHIVE_OK)
359
+ return (ARCHIVE_FATAL);
360
+ data->stream.next_out = data->compressed;
361
+ data->stream.avail_out =
362
+ (uInt)data->compressed_buffer_size;
363
+ }
364
+
365
+ /* If there's nothing to do, we're done. */
366
+ if (!finishing && data->stream.avail_in == 0)
367
+ return (ARCHIVE_OK);
368
+
369
+ ret = deflate(&(data->stream),
370
+ finishing ? Z_FINISH : Z_NO_FLUSH );
371
+
372
+ switch (ret) {
373
+ case Z_OK:
374
+ /* In non-finishing case, check if compressor
375
+ * consumed everything */
376
+ if (!finishing && data->stream.avail_in == 0)
377
+ return (ARCHIVE_OK);
378
+ /* In finishing case, this return always means
379
+ * there's more work */
380
+ break;
381
+ case Z_STREAM_END:
382
+ /* This return can only occur in finishing case. */
383
+ return (ARCHIVE_OK);
384
+ default:
385
+ /* Any other return value indicates an error. */
386
+ archive_set_error(f->archive, ARCHIVE_ERRNO_MISC,
387
+ "GZip compression failed:"
388
+ " deflate() call returned status %d",
389
+ ret);
390
+ return (ARCHIVE_FATAL);
391
+ }
392
+ }
393
+ }
394
+
395
+ #else /* HAVE_ZLIB_H */
396
+
397
+ static int
398
+ archive_compressor_gzip_open(struct archive_write_filter *f)
399
+ {
400
+ struct private_data *data = (struct private_data *)f->data;
401
+ struct archive_string as;
402
+ int r;
403
+
404
+ archive_string_init(&as);
405
+ archive_strcpy(&as, "gzip");
406
+
407
+ /* Specify compression level. */
408
+ if (data->compression_level > 0) {
409
+ archive_strcat(&as, " -");
410
+ archive_strappend_char(&as, '0' + data->compression_level);
411
+ }
412
+ if (data->timestamp < 0)
413
+ /* Do not save timestamp. */
414
+ archive_strcat(&as, " -n");
415
+ else if (data->timestamp > 0)
416
+ /* Save timestamp. */
417
+ archive_strcat(&as, " -N");
418
+
419
+ f->write = archive_compressor_gzip_write;
420
+ r = __archive_write_program_open(f, data->pdata, as.s);
421
+ archive_string_free(&as);
422
+ return (r);
423
+ }
424
+
425
+ static int
426
+ archive_compressor_gzip_write(struct archive_write_filter *f, const void *buff,
427
+ size_t length)
428
+ {
429
+ struct private_data *data = (struct private_data *)f->data;
430
+
431
+ return __archive_write_program_write(f, data->pdata, buff, length);
432
+ }
433
+
434
+ static int
435
+ archive_compressor_gzip_close(struct archive_write_filter *f)
436
+ {
437
+ struct private_data *data = (struct private_data *)f->data;
438
+
439
+ return __archive_write_program_close(f, data->pdata);
440
+ }
441
+
442
+ #endif /* HAVE_ZLIB_H */
@@ -0,0 +1,197 @@
1
+ /*-
2
+ * Copyright (c) 2003-2007 Tim Kientzle
3
+ * All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without
6
+ * modification, are permitted provided that the following conditions
7
+ * are met:
8
+ * 1. Redistributions of source code must retain the above copyright
9
+ * notice, this list of conditions and the following disclaimer.
10
+ * 2. Redistributions in binary form must reproduce the above copyright
11
+ * notice, this list of conditions and the following disclaimer in the
12
+ * documentation and/or other materials provided with the distribution.
13
+ *
14
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ */
25
+
26
+ #include "archive_platform.h"
27
+
28
+ __FBSDID("$FreeBSD$");
29
+
30
+ #ifdef HAVE_ERRNO_H
31
+ #include <errno.h>
32
+ #endif
33
+ #ifdef HAVE_STDLIB_H
34
+ #include <stdlib.h>
35
+ #endif
36
+ #ifdef HAVE_STRING_H
37
+ #include <string.h>
38
+ #endif
39
+
40
+ #include "archive.h"
41
+ #include "archive_string.h"
42
+ #include "archive_write_private.h"
43
+
44
+ struct write_lrzip {
45
+ struct archive_write_program_data *pdata;
46
+ int compression_level;
47
+ enum { lzma = 0, bzip2, gzip, lzo, none, zpaq } compression;
48
+ };
49
+
50
+ static int archive_write_lrzip_open(struct archive_write_filter *);
51
+ static int archive_write_lrzip_options(struct archive_write_filter *,
52
+ const char *, const char *);
53
+ static int archive_write_lrzip_write(struct archive_write_filter *,
54
+ const void *, size_t);
55
+ static int archive_write_lrzip_close(struct archive_write_filter *);
56
+ static int archive_write_lrzip_free(struct archive_write_filter *);
57
+
58
+ int
59
+ archive_write_add_filter_lrzip(struct archive *_a)
60
+ {
61
+ struct archive_write_filter *f = __archive_write_allocate_filter(_a);
62
+ struct write_lrzip *data;
63
+
64
+ archive_check_magic(_a, ARCHIVE_WRITE_MAGIC,
65
+ ARCHIVE_STATE_NEW, "archive_write_add_filter_lrzip");
66
+
67
+ data = calloc(1, sizeof(*data));
68
+ if (data == NULL) {
69
+ archive_set_error(_a, ENOMEM, "Can't allocate memory");
70
+ return (ARCHIVE_FATAL);
71
+ }
72
+ data->pdata = __archive_write_program_allocate("lrzip");
73
+ if (data->pdata == NULL) {
74
+ free(data);
75
+ archive_set_error(_a, ENOMEM, "Can't allocate memory");
76
+ return (ARCHIVE_FATAL);
77
+ }
78
+
79
+ f->name = "lrzip";
80
+ f->code = ARCHIVE_FILTER_LRZIP;
81
+ f->data = data;
82
+ f->open = archive_write_lrzip_open;
83
+ f->options = archive_write_lrzip_options;
84
+ f->write = archive_write_lrzip_write;
85
+ f->close = archive_write_lrzip_close;
86
+ f->free = archive_write_lrzip_free;
87
+
88
+ /* Note: This filter always uses an external program, so we
89
+ * return "warn" to inform of the fact. */
90
+ archive_set_error(_a, ARCHIVE_ERRNO_MISC,
91
+ "Using external lrzip program for lrzip compression");
92
+ return (ARCHIVE_WARN);
93
+ }
94
+
95
+ static int
96
+ archive_write_lrzip_options(struct archive_write_filter *f, const char *key,
97
+ const char *value)
98
+ {
99
+ struct write_lrzip *data = (struct write_lrzip *)f->data;
100
+
101
+ if (strcmp(key, "compression") == 0) {
102
+ if (value == NULL)
103
+ return (ARCHIVE_WARN);
104
+ else if (strcmp(value, "bzip2") == 0)
105
+ data->compression = bzip2;
106
+ else if (strcmp(value, "gzip") == 0)
107
+ data->compression = gzip;
108
+ else if (strcmp(value, "lzo") == 0)
109
+ data->compression = lzo;
110
+ else if (strcmp(value, "none") == 0)
111
+ data->compression = none;
112
+ else if (strcmp(value, "zpaq") == 0)
113
+ data->compression = zpaq;
114
+ else
115
+ return (ARCHIVE_WARN);
116
+ return (ARCHIVE_OK);
117
+ } else if (strcmp(key, "compression-level") == 0) {
118
+ if (value == NULL || !(value[0] >= '1' && value[0] <= '9') ||
119
+ value[1] != '\0')
120
+ return (ARCHIVE_WARN);
121
+ data->compression_level = value[0] - '0';
122
+ return (ARCHIVE_OK);
123
+ }
124
+ /* Note: The "warn" return is just to inform the options
125
+ * supervisor that we didn't handle it. It will generate
126
+ * a suitable error if no one used this option. */
127
+ return (ARCHIVE_WARN);
128
+ }
129
+
130
+ static int
131
+ archive_write_lrzip_open(struct archive_write_filter *f)
132
+ {
133
+ struct write_lrzip *data = (struct write_lrzip *)f->data;
134
+ struct archive_string as;
135
+ int r;
136
+
137
+ archive_string_init(&as);
138
+ archive_strcpy(&as, "lrzip -q");
139
+
140
+ /* Specify compression type. */
141
+ switch (data->compression) {
142
+ case lzma:/* default compression */
143
+ break;
144
+ case bzip2:
145
+ archive_strcat(&as, " -b");
146
+ break;
147
+ case gzip:
148
+ archive_strcat(&as, " -g");
149
+ break;
150
+ case lzo:
151
+ archive_strcat(&as, " -l");
152
+ break;
153
+ case none:
154
+ archive_strcat(&as, " -n");
155
+ break;
156
+ case zpaq:
157
+ archive_strcat(&as, " -z");
158
+ break;
159
+ }
160
+
161
+ /* Specify compression level. */
162
+ if (data->compression_level > 0) {
163
+ archive_strcat(&as, " -L ");
164
+ archive_strappend_char(&as, '0' + data->compression_level);
165
+ }
166
+
167
+ r = __archive_write_program_open(f, data->pdata, as.s);
168
+ archive_string_free(&as);
169
+ return (r);
170
+ }
171
+
172
+ static int
173
+ archive_write_lrzip_write(struct archive_write_filter *f,
174
+ const void *buff, size_t length)
175
+ {
176
+ struct write_lrzip *data = (struct write_lrzip *)f->data;
177
+
178
+ return __archive_write_program_write(f, data->pdata, buff, length);
179
+ }
180
+
181
+ static int
182
+ archive_write_lrzip_close(struct archive_write_filter *f)
183
+ {
184
+ struct write_lrzip *data = (struct write_lrzip *)f->data;
185
+
186
+ return __archive_write_program_close(f, data->pdata);
187
+ }
188
+
189
+ static int
190
+ archive_write_lrzip_free(struct archive_write_filter *f)
191
+ {
192
+ struct write_lrzip *data = (struct write_lrzip *)f->data;
193
+
194
+ __archive_write_program_free(data->pdata);
195
+ free(data);
196
+ return (ARCHIVE_OK);
197
+ }