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,586 @@
1
+ /*-
2
+ * Copyright (c) 2003-2010 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
+ __FBSDID("$FreeBSD: head/lib/libarchive/archive_read_open_filename.c 201093 2009-12-28 02:28:44Z kientzle $");
28
+
29
+ #ifdef HAVE_SYS_IOCTL_H
30
+ #include <sys/ioctl.h>
31
+ #endif
32
+ #ifdef HAVE_SYS_STAT_H
33
+ #include <sys/stat.h>
34
+ #endif
35
+ #ifdef HAVE_ERRNO_H
36
+ #include <errno.h>
37
+ #endif
38
+ #ifdef HAVE_FCNTL_H
39
+ #include <fcntl.h>
40
+ #endif
41
+ #ifdef HAVE_IO_H
42
+ #include <io.h>
43
+ #endif
44
+ #ifdef HAVE_STDLIB_H
45
+ #include <stdlib.h>
46
+ #endif
47
+ #ifdef HAVE_STRING_H
48
+ #include <string.h>
49
+ #endif
50
+ #ifdef HAVE_UNISTD_H
51
+ #include <unistd.h>
52
+ #endif
53
+ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
54
+ #include <sys/disk.h>
55
+ #elif defined(__NetBSD__) || defined(__OpenBSD__)
56
+ #include <sys/disklabel.h>
57
+ #include <sys/dkio.h>
58
+ #elif defined(__DragonFly__)
59
+ #include <sys/diskslice.h>
60
+ #endif
61
+
62
+ #include "archive.h"
63
+ #include "archive_private.h"
64
+ #include "archive_string.h"
65
+
66
+ #ifndef O_BINARY
67
+ #define O_BINARY 0
68
+ #endif
69
+ #ifndef O_CLOEXEC
70
+ #define O_CLOEXEC 0
71
+ #endif
72
+
73
+ struct read_file_data {
74
+ int fd;
75
+ size_t block_size;
76
+ void *buffer;
77
+ mode_t st_mode; /* Mode bits for opened file. */
78
+ char use_lseek;
79
+ enum fnt_e { FNT_STDIN, FNT_MBS, FNT_WCS } filename_type;
80
+ union {
81
+ char m[1];/* MBS filename. */
82
+ wchar_t w[1];/* WCS filename. */
83
+ } filename; /* Must be last! */
84
+ };
85
+
86
+ static int file_open(struct archive *, void *);
87
+ static int file_close(struct archive *, void *);
88
+ static int file_close2(struct archive *, void *);
89
+ static int file_switch(struct archive *, void *, void *);
90
+ static ssize_t file_read(struct archive *, void *, const void **buff);
91
+ static int64_t file_seek(struct archive *, void *, int64_t request, int);
92
+ static int64_t file_skip(struct archive *, void *, int64_t request);
93
+ static int64_t file_skip_lseek(struct archive *, void *, int64_t request);
94
+
95
+ int
96
+ archive_read_open_file(struct archive *a, const char *filename,
97
+ size_t block_size)
98
+ {
99
+ return (archive_read_open_filename(a, filename, block_size));
100
+ }
101
+
102
+ int
103
+ archive_read_open_filename(struct archive *a, const char *filename,
104
+ size_t block_size)
105
+ {
106
+ const char *filenames[2];
107
+ filenames[0] = filename;
108
+ filenames[1] = NULL;
109
+ return archive_read_open_filenames(a, filenames, block_size);
110
+ }
111
+
112
+ int
113
+ archive_read_open_filenames(struct archive *a, const char **filenames,
114
+ size_t block_size)
115
+ {
116
+ struct read_file_data *mine;
117
+ const char *filename = NULL;
118
+ if (filenames)
119
+ filename = *(filenames++);
120
+
121
+ archive_clear_error(a);
122
+ do
123
+ {
124
+ if (filename == NULL)
125
+ filename = "";
126
+ mine = (struct read_file_data *)calloc(1,
127
+ sizeof(*mine) + strlen(filename));
128
+ if (mine == NULL)
129
+ goto no_memory;
130
+ strcpy(mine->filename.m, filename);
131
+ mine->block_size = block_size;
132
+ mine->fd = -1;
133
+ mine->buffer = NULL;
134
+ mine->st_mode = mine->use_lseek = 0;
135
+ if (filename == NULL || filename[0] == '\0') {
136
+ mine->filename_type = FNT_STDIN;
137
+ } else
138
+ mine->filename_type = FNT_MBS;
139
+ if (archive_read_append_callback_data(a, mine) != (ARCHIVE_OK))
140
+ return (ARCHIVE_FATAL);
141
+ if (filenames == NULL)
142
+ break;
143
+ filename = *(filenames++);
144
+ } while (filename != NULL && filename[0] != '\0');
145
+ archive_read_set_open_callback(a, file_open);
146
+ archive_read_set_read_callback(a, file_read);
147
+ archive_read_set_skip_callback(a, file_skip);
148
+ archive_read_set_close_callback(a, file_close);
149
+ archive_read_set_switch_callback(a, file_switch);
150
+ archive_read_set_seek_callback(a, file_seek);
151
+
152
+ return (archive_read_open1(a));
153
+ no_memory:
154
+ archive_set_error(a, ENOMEM, "No memory");
155
+ return (ARCHIVE_FATAL);
156
+ }
157
+
158
+ int
159
+ archive_read_open_filename_w(struct archive *a, const wchar_t *wfilename,
160
+ size_t block_size)
161
+ {
162
+ struct read_file_data *mine = (struct read_file_data *)calloc(1,
163
+ sizeof(*mine) + wcslen(wfilename) * sizeof(wchar_t));
164
+ if (!mine)
165
+ {
166
+ archive_set_error(a, ENOMEM, "No memory");
167
+ return (ARCHIVE_FATAL);
168
+ }
169
+ mine->fd = -1;
170
+ mine->block_size = block_size;
171
+
172
+ if (wfilename == NULL || wfilename[0] == L'\0') {
173
+ mine->filename_type = FNT_STDIN;
174
+ } else {
175
+ #if defined(_WIN32) && !defined(__CYGWIN__)
176
+ mine->filename_type = FNT_WCS;
177
+ wcscpy(mine->filename.w, wfilename);
178
+ #else
179
+ /*
180
+ * POSIX system does not support a wchar_t interface for
181
+ * open() system call, so we have to translate a wchar_t
182
+ * filename to multi-byte one and use it.
183
+ */
184
+ struct archive_string fn;
185
+
186
+ archive_string_init(&fn);
187
+ if (archive_string_append_from_wcs(&fn, wfilename,
188
+ wcslen(wfilename)) != 0) {
189
+ if (errno == ENOMEM)
190
+ archive_set_error(a, errno,
191
+ "Can't allocate memory");
192
+ else
193
+ archive_set_error(a, EINVAL,
194
+ "Failed to convert a wide-character"
195
+ " filename to a multi-byte filename");
196
+ archive_string_free(&fn);
197
+ free(mine);
198
+ return (ARCHIVE_FATAL);
199
+ }
200
+ mine->filename_type = FNT_MBS;
201
+ strcpy(mine->filename.m, fn.s);
202
+ archive_string_free(&fn);
203
+ #endif
204
+ }
205
+ if (archive_read_append_callback_data(a, mine) != (ARCHIVE_OK))
206
+ return (ARCHIVE_FATAL);
207
+ archive_read_set_open_callback(a, file_open);
208
+ archive_read_set_read_callback(a, file_read);
209
+ archive_read_set_skip_callback(a, file_skip);
210
+ archive_read_set_close_callback(a, file_close);
211
+ archive_read_set_switch_callback(a, file_switch);
212
+ archive_read_set_seek_callback(a, file_seek);
213
+
214
+ return (archive_read_open1(a));
215
+ }
216
+
217
+ static int
218
+ file_open(struct archive *a, void *client_data)
219
+ {
220
+ struct stat st;
221
+ struct read_file_data *mine = (struct read_file_data *)client_data;
222
+ void *buffer;
223
+ const char *filename = NULL;
224
+ #if defined(_WIN32) && !defined(__CYGWIN__)
225
+ const wchar_t *wfilename = NULL;
226
+ #endif
227
+ int fd = -1;
228
+ int is_disk_like = 0;
229
+ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
230
+ off_t mediasize = 0; /* FreeBSD-specific, so off_t okay here. */
231
+ #elif defined(__NetBSD__) || defined(__OpenBSD__)
232
+ struct disklabel dl;
233
+ #elif defined(__DragonFly__)
234
+ struct partinfo pi;
235
+ #endif
236
+
237
+ archive_clear_error(a);
238
+ if (mine->filename_type == FNT_STDIN) {
239
+ /* We used to delegate stdin support by
240
+ * directly calling archive_read_open_fd(a,0,block_size)
241
+ * here, but that doesn't (and shouldn't) handle the
242
+ * end-of-file flush when reading stdout from a pipe.
243
+ * Basically, read_open_fd() is intended for folks who
244
+ * are willing to handle such details themselves. This
245
+ * API is intended to be a little smarter for folks who
246
+ * want easy handling of the common case.
247
+ */
248
+ fd = 0;
249
+ #if defined(__CYGWIN__) || defined(_WIN32)
250
+ setmode(0, O_BINARY);
251
+ #endif
252
+ filename = "";
253
+ } else if (mine->filename_type == FNT_MBS) {
254
+ filename = mine->filename.m;
255
+ fd = open(filename, O_RDONLY | O_BINARY | O_CLOEXEC);
256
+ __archive_ensure_cloexec_flag(fd);
257
+ if (fd < 0) {
258
+ archive_set_error(a, errno,
259
+ "Failed to open '%s'", filename);
260
+ return (ARCHIVE_FATAL);
261
+ }
262
+ } else {
263
+ #if defined(_WIN32) && !defined(__CYGWIN__)
264
+ wfilename = mine->filename.w;
265
+ fd = _wopen(wfilename, O_RDONLY | O_BINARY);
266
+ if (fd < 0 && errno == ENOENT) {
267
+ wchar_t *fullpath;
268
+ fullpath = __la_win_permissive_name_w(wfilename);
269
+ if (fullpath != NULL) {
270
+ fd = _wopen(fullpath, O_RDONLY | O_BINARY);
271
+ free(fullpath);
272
+ }
273
+ }
274
+ if (fd < 0) {
275
+ archive_set_error(a, errno,
276
+ "Failed to open '%S'", wfilename);
277
+ return (ARCHIVE_FATAL);
278
+ }
279
+ #else
280
+ archive_set_error(a, ARCHIVE_ERRNO_MISC,
281
+ "Unexpedted operation in archive_read_open_filename");
282
+ goto fail;
283
+ #endif
284
+ }
285
+ if (fstat(fd, &st) != 0) {
286
+ #if defined(_WIN32) && !defined(__CYGWIN__)
287
+ if (mine->filename_type == FNT_WCS)
288
+ archive_set_error(a, errno, "Can't stat '%S'",
289
+ wfilename);
290
+ else
291
+ #endif
292
+ archive_set_error(a, errno, "Can't stat '%s'",
293
+ filename);
294
+ goto fail;
295
+ }
296
+
297
+ /*
298
+ * Determine whether the input looks like a disk device or a
299
+ * tape device. The results are used below to select an I/O
300
+ * strategy:
301
+ * = "disk-like" devices support arbitrary lseek() and will
302
+ * support I/O requests of any size. So we get easy skipping
303
+ * and can cheat on block sizes to get better performance.
304
+ * = "tape-like" devices require strict blocking and use
305
+ * specialized ioctls for seeking.
306
+ * = "socket-like" devices cannot seek at all but can improve
307
+ * performance by using nonblocking I/O to read "whatever is
308
+ * available right now".
309
+ *
310
+ * Right now, we only specially recognize disk-like devices,
311
+ * but it should be straightforward to add probes and strategy
312
+ * here for tape-like and socket-like devices.
313
+ */
314
+ if (S_ISREG(st.st_mode)) {
315
+ /* Safety: Tell the extractor not to overwrite the input. */
316
+ archive_read_extract_set_skip_file(a, st.st_dev, st.st_ino);
317
+ /* Regular files act like disks. */
318
+ is_disk_like = 1;
319
+ }
320
+ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
321
+ /* FreeBSD: if it supports DIOCGMEDIASIZE ioctl, it's disk-like. */
322
+ else if (S_ISCHR(st.st_mode) &&
323
+ ioctl(fd, DIOCGMEDIASIZE, &mediasize) == 0 &&
324
+ mediasize > 0) {
325
+ is_disk_like = 1;
326
+ }
327
+ #elif defined(__NetBSD__) || defined(__OpenBSD__)
328
+ /* Net/OpenBSD: if it supports DIOCGDINFO ioctl, it's disk-like. */
329
+ else if ((S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) &&
330
+ ioctl(fd, DIOCGDINFO, &dl) == 0 &&
331
+ dl.d_partitions[DISKPART(st.st_rdev)].p_size > 0) {
332
+ is_disk_like = 1;
333
+ }
334
+ #elif defined(__DragonFly__)
335
+ /* DragonFly BSD: if it supports DIOCGPART ioctl, it's disk-like. */
336
+ else if (S_ISCHR(st.st_mode) &&
337
+ ioctl(fd, DIOCGPART, &pi) == 0 &&
338
+ pi.media_size > 0) {
339
+ is_disk_like = 1;
340
+ }
341
+ #elif defined(__linux__)
342
+ /* Linux: All block devices are disk-like. */
343
+ else if (S_ISBLK(st.st_mode) &&
344
+ lseek(fd, 0, SEEK_CUR) == 0 &&
345
+ lseek(fd, 0, SEEK_SET) == 0 &&
346
+ lseek(fd, 0, SEEK_END) > 0 &&
347
+ lseek(fd, 0, SEEK_SET) == 0) {
348
+ is_disk_like = 1;
349
+ }
350
+ #endif
351
+ /* TODO: Add an "is_tape_like" variable and appropriate tests. */
352
+
353
+ /* Disk-like devices prefer power-of-two block sizes. */
354
+ /* Use provided block_size as a guide so users have some control. */
355
+ if (is_disk_like) {
356
+ size_t new_block_size = 64 * 1024;
357
+ while (new_block_size < mine->block_size
358
+ && new_block_size < 64 * 1024 * 1024)
359
+ new_block_size *= 2;
360
+ mine->block_size = new_block_size;
361
+ }
362
+ buffer = malloc(mine->block_size);
363
+ if (buffer == NULL) {
364
+ archive_set_error(a, ENOMEM, "No memory");
365
+ goto fail;
366
+ }
367
+ mine->buffer = buffer;
368
+ mine->fd = fd;
369
+ /* Remember mode so close can decide whether to flush. */
370
+ mine->st_mode = st.st_mode;
371
+
372
+ /* Disk-like inputs can use lseek(). */
373
+ if (is_disk_like)
374
+ mine->use_lseek = 1;
375
+
376
+ return (ARCHIVE_OK);
377
+ fail:
378
+ /*
379
+ * Don't close file descriptors not opened or ones pointing referring
380
+ * to `FNT_STDIN`.
381
+ */
382
+ if (fd != -1 && fd != 0)
383
+ close(fd);
384
+ return (ARCHIVE_FATAL);
385
+ }
386
+
387
+ static ssize_t
388
+ file_read(struct archive *a, void *client_data, const void **buff)
389
+ {
390
+ struct read_file_data *mine = (struct read_file_data *)client_data;
391
+ ssize_t bytes_read;
392
+
393
+ /* TODO: If a recent lseek() operation has left us
394
+ * mis-aligned, read and return a short block to try to get
395
+ * us back in alignment. */
396
+
397
+ /* TODO: Someday, try mmap() here; if that succeeds, give
398
+ * the entire file to libarchive as a single block. That
399
+ * could be a lot faster than block-by-block manual I/O. */
400
+
401
+ /* TODO: We might be able to improve performance on pipes and
402
+ * sockets by setting non-blocking I/O and just accepting
403
+ * whatever we get here instead of waiting for a full block
404
+ * worth of data. */
405
+
406
+ *buff = mine->buffer;
407
+ for (;;) {
408
+ bytes_read = read(mine->fd, mine->buffer, mine->block_size);
409
+ if (bytes_read < 0) {
410
+ if (errno == EINTR)
411
+ continue;
412
+ else if (mine->filename_type == FNT_STDIN)
413
+ archive_set_error(a, errno,
414
+ "Error reading stdin");
415
+ else if (mine->filename_type == FNT_MBS)
416
+ archive_set_error(a, errno,
417
+ "Error reading '%s'", mine->filename.m);
418
+ else
419
+ archive_set_error(a, errno,
420
+ "Error reading '%S'", mine->filename.w);
421
+ }
422
+ return (bytes_read);
423
+ }
424
+ }
425
+
426
+ /*
427
+ * Regular files and disk-like block devices can use simple lseek
428
+ * without needing to round the request to the block size.
429
+ *
430
+ * TODO: This can leave future reads mis-aligned. Since we know the
431
+ * offset here, we should store it and use it in file_read() above
432
+ * to determine whether we should perform a short read to get back
433
+ * into alignment. Long series of mis-aligned reads can negatively
434
+ * impact disk throughput. (Of course, the performance impact should
435
+ * be carefully tested; extra code complexity is only worthwhile if
436
+ * it does provide measurable improvement.)
437
+ *
438
+ * TODO: Be lazy about the actual seek. There are a few pathological
439
+ * cases where libarchive makes a bunch of seek requests in a row
440
+ * without any intervening reads. This isn't a huge performance
441
+ * problem, since the kernel handles seeks lazily already, but
442
+ * it would be very slightly faster if we simply remembered the
443
+ * seek request here and then actually performed the seek at the
444
+ * top of the read callback above.
445
+ */
446
+ static int64_t
447
+ file_skip_lseek(struct archive *a, void *client_data, int64_t request)
448
+ {
449
+ struct read_file_data *mine = (struct read_file_data *)client_data;
450
+ #if defined(_WIN32) && !defined(__CYGWIN__)
451
+ /* We use _lseeki64() on Windows. */
452
+ int64_t old_offset, new_offset;
453
+ #else
454
+ off_t old_offset, new_offset;
455
+ #endif
456
+
457
+ /* We use off_t here because lseek() is declared that way. */
458
+
459
+ /* TODO: Deal with case where off_t isn't 64 bits.
460
+ * This shouldn't be a problem on Linux or other POSIX
461
+ * systems, since the configuration logic for libarchive
462
+ * tries to obtain a 64-bit off_t.
463
+ */
464
+ if ((old_offset = lseek(mine->fd, 0, SEEK_CUR)) >= 0 &&
465
+ (new_offset = lseek(mine->fd, request, SEEK_CUR)) >= 0)
466
+ return (new_offset - old_offset);
467
+
468
+ /* If lseek() fails, don't bother trying again. */
469
+ mine->use_lseek = 0;
470
+
471
+ /* Let libarchive recover with read+discard */
472
+ if (errno == ESPIPE)
473
+ return (0);
474
+
475
+ /* If the input is corrupted or truncated, fail. */
476
+ if (mine->filename_type == FNT_STDIN)
477
+ archive_set_error(a, errno, "Error seeking in stdin");
478
+ else if (mine->filename_type == FNT_MBS)
479
+ archive_set_error(a, errno, "Error seeking in '%s'",
480
+ mine->filename.m);
481
+ else
482
+ archive_set_error(a, errno, "Error seeking in '%S'",
483
+ mine->filename.w);
484
+ return (-1);
485
+ }
486
+
487
+
488
+ /*
489
+ * TODO: Implement another file_skip_XXXX that uses MTIO ioctls to
490
+ * accelerate operation on tape drives.
491
+ */
492
+
493
+ static int64_t
494
+ file_skip(struct archive *a, void *client_data, int64_t request)
495
+ {
496
+ struct read_file_data *mine = (struct read_file_data *)client_data;
497
+
498
+ /* Delegate skip requests. */
499
+ if (mine->use_lseek)
500
+ return (file_skip_lseek(a, client_data, request));
501
+
502
+ /* If we can't skip, return 0; libarchive will read+discard instead. */
503
+ return (0);
504
+ }
505
+
506
+ /*
507
+ * TODO: Store the offset and use it in the read callback.
508
+ */
509
+ static int64_t
510
+ file_seek(struct archive *a, void *client_data, int64_t request, int whence)
511
+ {
512
+ struct read_file_data *mine = (struct read_file_data *)client_data;
513
+ int64_t r;
514
+
515
+ /* We use off_t here because lseek() is declared that way. */
516
+ /* See above for notes about when off_t is less than 64 bits. */
517
+ r = lseek(mine->fd, request, whence);
518
+ if (r >= 0)
519
+ return r;
520
+
521
+ /* If the input is corrupted or truncated, fail. */
522
+ if (mine->filename_type == FNT_STDIN)
523
+ archive_set_error(a, errno, "Error seeking in stdin");
524
+ else if (mine->filename_type == FNT_MBS)
525
+ archive_set_error(a, errno, "Error seeking in '%s'",
526
+ mine->filename.m);
527
+ else
528
+ archive_set_error(a, errno, "Error seeking in '%S'",
529
+ mine->filename.w);
530
+ return (ARCHIVE_FATAL);
531
+ }
532
+
533
+ static int
534
+ file_close2(struct archive *a, void *client_data)
535
+ {
536
+ struct read_file_data *mine = (struct read_file_data *)client_data;
537
+
538
+ (void)a; /* UNUSED */
539
+
540
+ /* Only flush and close if open succeeded. */
541
+ if (mine->fd >= 0) {
542
+ /*
543
+ * Sometimes, we should flush the input before closing.
544
+ * Regular files: faster to just close without flush.
545
+ * Disk-like devices: Ditto.
546
+ * Tapes: must not flush (user might need to
547
+ * read the "next" item on a non-rewind device).
548
+ * Pipes and sockets: must flush (otherwise, the
549
+ * program feeding the pipe or socket may complain).
550
+ * Here, I flush everything except for regular files and
551
+ * device nodes.
552
+ */
553
+ if (!S_ISREG(mine->st_mode)
554
+ && !S_ISCHR(mine->st_mode)
555
+ && !S_ISBLK(mine->st_mode)) {
556
+ ssize_t bytesRead;
557
+ do {
558
+ bytesRead = read(mine->fd, mine->buffer,
559
+ mine->block_size);
560
+ } while (bytesRead > 0);
561
+ }
562
+ /* If a named file was opened, then it needs to be closed. */
563
+ if (mine->filename_type != FNT_STDIN)
564
+ close(mine->fd);
565
+ }
566
+ free(mine->buffer);
567
+ mine->buffer = NULL;
568
+ mine->fd = -1;
569
+ return (ARCHIVE_OK);
570
+ }
571
+
572
+ static int
573
+ file_close(struct archive *a, void *client_data)
574
+ {
575
+ struct read_file_data *mine = (struct read_file_data *)client_data;
576
+ file_close2(a, client_data);
577
+ free(mine);
578
+ return (ARCHIVE_OK);
579
+ }
580
+
581
+ static int
582
+ file_switch(struct archive *a, void *client_data1, void *client_data2)
583
+ {
584
+ file_close2(a, client_data1);
585
+ return file_open(a, client_data2);
586
+ }