@papyrus-sdk/engine-native 0.2.22-beta.9.epub.2 → 0.2.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/PapyrusNativeEngine.podspec +45 -0
- package/android/build.gradle +1 -0
- package/android/src/main/cpp/CMakeLists.txt +137 -0
- package/android/src/main/cpp/PapyrusComicArchiveJni.cpp +68 -0
- package/android/src/main/cpp/PapyrusComicArchiveTest.cpp +55 -0
- package/android/src/main/cpp/papyrus_outline_loader_test.cpp +240 -0
- package/android/src/main/cpp/papyrus_text_word_test.cpp +72 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusComicArchiveNative.java +14 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusComicDocumentView.java +491 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusComicDocumentViewManager.java +32 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusComicPageLayout.java +38 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusNativeEngineModule.java +305 -35
- package/android/src/main/java/com/papyrus/engine/PapyrusNativeTextModel.java +195 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusPackage.java +3 -1
- package/android/src/main/java/com/papyrus/engine/PapyrusPdfViewerView.java +195 -5
- package/android/src/main/java/com/papyrus/engine/PapyrusPdfViewerViewManager.java +20 -1
- package/android/src/main/java/com/papyrus/engine/PapyrusSelectionMenuIcon.java +48 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusTextAnnotationModel.java +22 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusTextDocumentView.java +661 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusTextDocumentViewManager.java +49 -0
- package/android/src/main/java/com/papyrus/engine/PapyrusTextStore.java +43 -0
- package/dist/index.d.mts +614 -4
- package/dist/index.d.ts +614 -4
- package/dist/index.js +484 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +477 -7
- package/dist/index.mjs.map +1 -1
- package/ios/PapyrusComicDocumentView.h +21 -0
- package/ios/PapyrusComicDocumentView.m +554 -0
- package/ios/PapyrusComicDocumentViewManager.m +23 -0
- package/ios/PapyrusEngineStore.h +3 -0
- package/ios/PapyrusEngineStore.m +32 -6
- package/ios/PapyrusNativeEngine.m +684 -5
- package/ios/PapyrusPageRotationRegistry.h +29 -0
- package/ios/PapyrusPageRotationRegistry.m +179 -0
- package/ios/PapyrusPageView.m +38 -11
- package/ios/PapyrusPdfDocumentView.h +55 -0
- package/ios/PapyrusPdfDocumentView.m +2370 -0
- package/ios/PapyrusPdfDocumentViewManager.m +61 -0
- package/ios/PapyrusPdfPageTheme.h +15 -0
- package/ios/PapyrusPdfPageTheme.m +218 -0
- package/ios/PapyrusSelectionMenu.h +27 -0
- package/ios/PapyrusTextAnnotationRange.h +2 -0
- package/ios/PapyrusTextAnnotationRange.m +29 -0
- package/ios/PapyrusTextDocumentView.h +32 -0
- package/ios/PapyrusTextDocumentView.m +518 -0
- package/ios/PapyrusTextDocumentViewManager.m +34 -0
- package/ios/PapyrusTextStore.h +13 -0
- package/ios/PapyrusTextStore.m +73 -0
- package/package.json +12 -10
- package/react-native.config.js +1 -1
- package/third_party_licenses/BLAKE2-NOTICE.txt +11 -0
- package/third_party_licenses/libarchive-COPYING +65 -0
- package/vendor/libarchive/PapyrusComicArchive.cpp +376 -0
- package/vendor/libarchive/PapyrusComicArchive.h +30 -0
- package/vendor/libarchive/README.papyrus.md +15 -0
- package/vendor/libarchive/android.h +192 -0
- package/vendor/libarchive/config/PapyrusArchiveConfig.h +71 -0
- package/vendor/libarchive/libarchive/CMakeLists.txt +293 -0
- package/vendor/libarchive/libarchive/android_lf.h +36 -0
- package/vendor/libarchive/libarchive/archive.h +1266 -0
- package/vendor/libarchive/libarchive/archive_acl.c +2025 -0
- package/vendor/libarchive/libarchive/archive_acl_private.h +85 -0
- package/vendor/libarchive/libarchive/archive_blake2.h +197 -0
- package/vendor/libarchive/libarchive/archive_blake2_impl.h +161 -0
- package/vendor/libarchive/libarchive/archive_blake2s_ref.c +369 -0
- package/vendor/libarchive/libarchive/archive_blake2sp_ref.c +361 -0
- package/vendor/libarchive/libarchive/archive_check_magic.c +183 -0
- package/vendor/libarchive/libarchive/archive_cmdline.c +211 -0
- package/vendor/libarchive/libarchive/archive_cmdline_private.h +45 -0
- package/vendor/libarchive/libarchive/archive_crc32.h +123 -0
- package/vendor/libarchive/libarchive/archive_cryptor.c +534 -0
- package/vendor/libarchive/libarchive/archive_cryptor_private.h +199 -0
- package/vendor/libarchive/libarchive/archive_digest.c +1584 -0
- package/vendor/libarchive/libarchive/archive_digest_private.h +431 -0
- package/vendor/libarchive/libarchive/archive_disk_acl_darwin.c +558 -0
- package/vendor/libarchive/libarchive/archive_disk_acl_freebsd.c +712 -0
- package/vendor/libarchive/libarchive/archive_disk_acl_linux.c +760 -0
- package/vendor/libarchive/libarchive/archive_disk_acl_sunos.c +824 -0
- package/vendor/libarchive/libarchive/archive_endian.h +234 -0
- package/vendor/libarchive/libarchive/archive_entry.3 +147 -0
- package/vendor/libarchive/libarchive/archive_entry.c +2297 -0
- package/vendor/libarchive/libarchive/archive_entry.h +763 -0
- package/vendor/libarchive/libarchive/archive_entry_acl.3 +458 -0
- package/vendor/libarchive/libarchive/archive_entry_copy_bhfi.c +55 -0
- package/vendor/libarchive/libarchive/archive_entry_copy_stat.c +82 -0
- package/vendor/libarchive/libarchive/archive_entry_link_resolver.c +472 -0
- package/vendor/libarchive/libarchive/archive_entry_linkify.3 +224 -0
- package/vendor/libarchive/libarchive/archive_entry_locale.h +90 -0
- package/vendor/libarchive/libarchive/archive_entry_misc.3 +63 -0
- package/vendor/libarchive/libarchive/archive_entry_paths.3 +153 -0
- package/vendor/libarchive/libarchive/archive_entry_perms.3 +210 -0
- package/vendor/libarchive/libarchive/archive_entry_private.h +205 -0
- package/vendor/libarchive/libarchive/archive_entry_sparse.c +156 -0
- package/vendor/libarchive/libarchive/archive_entry_stat.3 +274 -0
- package/vendor/libarchive/libarchive/archive_entry_stat.c +121 -0
- package/vendor/libarchive/libarchive/archive_entry_strmode.c +69 -0
- package/vendor/libarchive/libarchive/archive_entry_time.3 +127 -0
- package/vendor/libarchive/libarchive/archive_entry_xattr.c +155 -0
- package/vendor/libarchive/libarchive/archive_hmac.c +345 -0
- package/vendor/libarchive/libarchive/archive_hmac_private.h +119 -0
- package/vendor/libarchive/libarchive/archive_integer.h +267 -0
- package/vendor/libarchive/libarchive/archive_match.c +1869 -0
- package/vendor/libarchive/libarchive/archive_openssl_evp_private.h +54 -0
- package/vendor/libarchive/libarchive/archive_openssl_hmac_private.h +54 -0
- package/vendor/libarchive/libarchive/archive_options.c +219 -0
- package/vendor/libarchive/libarchive/archive_options_private.h +49 -0
- package/vendor/libarchive/libarchive/archive_pack_dev.c +330 -0
- package/vendor/libarchive/libarchive/archive_pack_dev.h +49 -0
- package/vendor/libarchive/libarchive/archive_parse_date.c +1173 -0
- package/vendor/libarchive/libarchive/archive_pathmatch.c +480 -0
- package/vendor/libarchive/libarchive/archive_pathmatch.h +50 -0
- package/vendor/libarchive/libarchive/archive_platform.h +213 -0
- package/vendor/libarchive/libarchive/archive_platform_acl.h +53 -0
- package/vendor/libarchive/libarchive/archive_platform_stat.h +45 -0
- package/vendor/libarchive/libarchive/archive_platform_xattr.h +45 -0
- package/vendor/libarchive/libarchive/archive_ppmd7.c +1173 -0
- package/vendor/libarchive/libarchive/archive_ppmd7_private.h +119 -0
- package/vendor/libarchive/libarchive/archive_ppmd8.c +1293 -0
- package/vendor/libarchive/libarchive/archive_ppmd8_private.h +123 -0
- package/vendor/libarchive/libarchive/archive_ppmd_private.h +159 -0
- package/vendor/libarchive/libarchive/archive_private.h +209 -0
- package/vendor/libarchive/libarchive/archive_random.c +274 -0
- package/vendor/libarchive/libarchive/archive_random_private.h +36 -0
- package/vendor/libarchive/libarchive/archive_rb.c +709 -0
- package/vendor/libarchive/libarchive/archive_rb.h +113 -0
- package/vendor/libarchive/libarchive/archive_read.3 +250 -0
- package/vendor/libarchive/libarchive/archive_read.c +1814 -0
- package/vendor/libarchive/libarchive/archive_read_add_passphrase.3 +72 -0
- package/vendor/libarchive/libarchive/archive_read_add_passphrase.c +189 -0
- package/vendor/libarchive/libarchive/archive_read_append_filter.c +209 -0
- package/vendor/libarchive/libarchive/archive_read_data.3 +128 -0
- package/vendor/libarchive/libarchive/archive_read_data_into_fd.c +207 -0
- package/vendor/libarchive/libarchive/archive_read_disk.3 +422 -0
- package/vendor/libarchive/libarchive/archive_read_disk_entry_from_file.c +1086 -0
- package/vendor/libarchive/libarchive/archive_read_disk_posix.c +2639 -0
- package/vendor/libarchive/libarchive/archive_read_disk_private.h +97 -0
- package/vendor/libarchive/libarchive/archive_read_disk_set_standard_lookup.c +315 -0
- package/vendor/libarchive/libarchive/archive_read_disk_windows.c +2603 -0
- package/vendor/libarchive/libarchive/archive_read_extract.3 +135 -0
- package/vendor/libarchive/libarchive/archive_read_extract.c +59 -0
- package/vendor/libarchive/libarchive/archive_read_extract2.c +154 -0
- package/vendor/libarchive/libarchive/archive_read_filter.3 +163 -0
- package/vendor/libarchive/libarchive/archive_read_format.3 +190 -0
- package/vendor/libarchive/libarchive/archive_read_free.3 +91 -0
- package/vendor/libarchive/libarchive/archive_read_header.3 +89 -0
- package/vendor/libarchive/libarchive/archive_read_new.3 +57 -0
- package/vendor/libarchive/libarchive/archive_read_open.3 +247 -0
- package/vendor/libarchive/libarchive/archive_read_open_fd.c +236 -0
- package/vendor/libarchive/libarchive/archive_read_open_file.c +257 -0
- package/vendor/libarchive/libarchive/archive_read_open_filename.c +652 -0
- package/vendor/libarchive/libarchive/archive_read_open_memory.c +188 -0
- package/vendor/libarchive/libarchive/archive_read_private.h +274 -0
- package/vendor/libarchive/libarchive/archive_read_set_format.c +116 -0
- package/vendor/libarchive/libarchive/archive_read_set_options.3 +290 -0
- package/vendor/libarchive/libarchive/archive_read_set_options.c +132 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_all.c +84 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_by_code.c +68 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_bzip2.c +360 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_compress.c +457 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_grzip.c +108 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_gzip.c +538 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_lrzip.c +119 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_lz4.c +829 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_lzop.c +493 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_none.c +51 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_program.c +497 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_rpm.c +249 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_uu.c +739 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_xz.c +792 -0
- package/vendor/libarchive/libarchive/archive_read_support_filter_zstd.c +356 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_7zip.c +4650 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_all.c +88 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_ar.c +597 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_by_code.c +76 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_cab.c +3410 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_cpio.c +1152 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_empty.c +95 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_iso9660.c +3516 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_lha.c +2931 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_mtree.c +2113 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_rar.c +3932 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_rar5.c +4501 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_raw.c +194 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_tar.c +3785 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_warc.c +875 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_xar.c +3770 -0
- package/vendor/libarchive/libarchive/archive_read_support_format_zip.c +4710 -0
- package/vendor/libarchive/libarchive/archive_string.c +4391 -0
- package/vendor/libarchive/libarchive/archive_string.h +244 -0
- package/vendor/libarchive/libarchive/archive_string_composition.h +2289 -0
- package/vendor/libarchive/libarchive/archive_string_sprintf.c +200 -0
- package/vendor/libarchive/libarchive/archive_time.c +168 -0
- package/vendor/libarchive/libarchive/archive_time_private.h +47 -0
- package/vendor/libarchive/libarchive/archive_util.3 +239 -0
- package/vendor/libarchive/libarchive/archive_util.c +668 -0
- package/vendor/libarchive/libarchive/archive_version_details.c +516 -0
- package/vendor/libarchive/libarchive/archive_virtual.c +162 -0
- package/vendor/libarchive/libarchive/archive_windows.c +1035 -0
- package/vendor/libarchive/libarchive/archive_windows.h +332 -0
- package/vendor/libarchive/libarchive/archive_write.3 +266 -0
- package/vendor/libarchive/libarchive/archive_write.c +896 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter.c +71 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_b64encode.c +329 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_by_name.c +76 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_bzip2.c +411 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_compress.c +459 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_grzip.c +143 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_gzip.c +493 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_lrzip.c +214 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_lz4.c +710 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_lzop.c +500 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_none.c +42 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_program.c +398 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_uuencode.c +320 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_xz.c +547 -0
- package/vendor/libarchive/libarchive/archive_write_add_filter_zstd.c +608 -0
- package/vendor/libarchive/libarchive/archive_write_blocksize.3 +112 -0
- package/vendor/libarchive/libarchive/archive_write_data.3 +88 -0
- package/vendor/libarchive/libarchive/archive_write_disk.3 +360 -0
- package/vendor/libarchive/libarchive/archive_write_disk_posix.c +4789 -0
- package/vendor/libarchive/libarchive/archive_write_disk_private.h +43 -0
- package/vendor/libarchive/libarchive/archive_write_disk_set_standard_lookup.c +265 -0
- package/vendor/libarchive/libarchive/archive_write_disk_windows.c +2952 -0
- package/vendor/libarchive/libarchive/archive_write_filter.3 +140 -0
- package/vendor/libarchive/libarchive/archive_write_finish_entry.3 +77 -0
- package/vendor/libarchive/libarchive/archive_write_format.3 +187 -0
- package/vendor/libarchive/libarchive/archive_write_free.3 +94 -0
- package/vendor/libarchive/libarchive/archive_write_header.3 +71 -0
- package/vendor/libarchive/libarchive/archive_write_new.3 +56 -0
- package/vendor/libarchive/libarchive/archive_write_open.3 +270 -0
- package/vendor/libarchive/libarchive/archive_write_open_fd.c +141 -0
- package/vendor/libarchive/libarchive/archive_write_open_file.c +102 -0
- package/vendor/libarchive/libarchive/archive_write_open_filename.c +272 -0
- package/vendor/libarchive/libarchive/archive_write_open_memory.c +110 -0
- package/vendor/libarchive/libarchive/archive_write_private.h +166 -0
- package/vendor/libarchive/libarchive/archive_write_set_format.c +124 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_7zip.c +2571 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_ar.c +540 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_by_name.c +93 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_cpio.c +11 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_cpio_binary.c +618 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_cpio_newc.c +457 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_cpio_odc.c +508 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_filter_by_ext.c +141 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_gnutar.c +790 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_iso9660.c +8216 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_mtree.c +2307 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_pax.c +2249 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_private.h +40 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_raw.c +123 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_shar.c +650 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_ustar.c +768 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_v7tar.c +648 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_warc.c +491 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_xar.c +3799 -0
- package/vendor/libarchive/libarchive/archive_write_set_format_zip.c +2548 -0
- package/vendor/libarchive/libarchive/archive_write_set_options.3 +779 -0
- package/vendor/libarchive/libarchive/archive_write_set_options.c +129 -0
- package/vendor/libarchive/libarchive/archive_write_set_passphrase.3 +72 -0
- package/vendor/libarchive/libarchive/archive_write_set_passphrase.c +95 -0
- package/vendor/libarchive/libarchive/archive_xxhash.h +48 -0
- package/vendor/libarchive/libarchive/config_freebsd.h +275 -0
- package/vendor/libarchive/libarchive/cpio.5 +389 -0
- package/vendor/libarchive/libarchive/filter_fork.h +44 -0
- package/vendor/libarchive/libarchive/filter_fork_posix.c +269 -0
- package/vendor/libarchive/libarchive/filter_fork_windows.c +270 -0
- package/vendor/libarchive/libarchive/libarchive-formats.5 +478 -0
- package/vendor/libarchive/libarchive/libarchive.3 +297 -0
- package/vendor/libarchive/libarchive/libarchive_changes.3 +339 -0
- package/vendor/libarchive/libarchive/libarchive_internals.3 +363 -0
- package/vendor/libarchive/libarchive/module.modulemap +34 -0
- package/vendor/libarchive/libarchive/mtree.5 +323 -0
- package/vendor/libarchive/libarchive/tar.5 +947 -0
- package/vendor/libarchive/libarchive/xxhash.c +531 -0
- package/ios/PapyrusNativeEngine.podspec +0 -15
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
.\" Copyright (c) 2003-2011 Tim Kientzle
|
|
2
|
+
.\" All rights reserved.
|
|
3
|
+
.\"
|
|
4
|
+
.\" Redistribution and use in source and binary forms, with or without
|
|
5
|
+
.\" modification, are permitted provided that the following conditions
|
|
6
|
+
.\" are met:
|
|
7
|
+
.\" 1. Redistributions of source code must retain the above copyright
|
|
8
|
+
.\" notice, this list of conditions and the following disclaimer.
|
|
9
|
+
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
10
|
+
.\" notice, this list of conditions and the following disclaimer in the
|
|
11
|
+
.\" documentation and/or other materials provided with the distribution.
|
|
12
|
+
.\"
|
|
13
|
+
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
14
|
+
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
15
|
+
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
16
|
+
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
17
|
+
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
18
|
+
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
19
|
+
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
20
|
+
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
21
|
+
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
22
|
+
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
23
|
+
.\" SUCH DAMAGE.
|
|
24
|
+
.\"
|
|
25
|
+
.Dd November 12, 2020
|
|
26
|
+
.Dt ARCHIVE_WRITE_OPEN 3
|
|
27
|
+
.Os
|
|
28
|
+
.Sh NAME
|
|
29
|
+
.Nm archive_write_open ,
|
|
30
|
+
.Nm archive_write_open2 ,
|
|
31
|
+
.Nm archive_write_open_fd ,
|
|
32
|
+
.Nm archive_write_open_FILE ,
|
|
33
|
+
.Nm archive_write_open_filename ,
|
|
34
|
+
.Nm archive_write_open_memory
|
|
35
|
+
.Nd functions for creating archives
|
|
36
|
+
.Sh LIBRARY
|
|
37
|
+
Streaming Archive Library (libarchive, -larchive)
|
|
38
|
+
.Sh SYNOPSIS
|
|
39
|
+
.In archive.h
|
|
40
|
+
.Ft int
|
|
41
|
+
.Fo archive_write_open
|
|
42
|
+
.Fa "struct archive *"
|
|
43
|
+
.Fa "void *client_data"
|
|
44
|
+
.Fa "archive_open_callback *"
|
|
45
|
+
.Fa "archive_write_callback *"
|
|
46
|
+
.Fa "archive_close_callback *"
|
|
47
|
+
.Fc
|
|
48
|
+
.Ft int
|
|
49
|
+
.Fo archive_write_open2
|
|
50
|
+
.Fa "struct archive *"
|
|
51
|
+
.Fa "void *client_data"
|
|
52
|
+
.Fa "archive_open_callback *"
|
|
53
|
+
.Fa "archive_write_callback *"
|
|
54
|
+
.Fa "archive_close_callback *"
|
|
55
|
+
.Fa "archive_free_callback *"
|
|
56
|
+
.Fc
|
|
57
|
+
.Ft int
|
|
58
|
+
.Fn archive_write_open_fd "struct archive *" "int fd"
|
|
59
|
+
.Ft int
|
|
60
|
+
.Fn archive_write_open_FILE "struct archive *" "FILE *file"
|
|
61
|
+
.Ft int
|
|
62
|
+
.Fn archive_write_open_filename "struct archive *" "const char *filename"
|
|
63
|
+
.Ft int
|
|
64
|
+
.Fo archive_write_open_memory
|
|
65
|
+
.Fa "struct archive *"
|
|
66
|
+
.Fa "void *buffer"
|
|
67
|
+
.Fa "size_t bufferSize"
|
|
68
|
+
.Fa "size_t *outUsed"
|
|
69
|
+
.Fc
|
|
70
|
+
.Sh DESCRIPTION
|
|
71
|
+
.Bl -tag -width indent
|
|
72
|
+
.It Fn archive_write_open
|
|
73
|
+
Freeze the settings, open the archive, and prepare for writing entries.
|
|
74
|
+
This is the most generic form of this function, which accepts
|
|
75
|
+
pointers to three callback functions which will be invoked by
|
|
76
|
+
the compression layer to write the constructed archive.
|
|
77
|
+
This does not alter the default archive padding.
|
|
78
|
+
.It Fn archive_write_open2
|
|
79
|
+
Same as
|
|
80
|
+
.Fn archive_write_open
|
|
81
|
+
with an additional fourth free callback. This function should be preferred to
|
|
82
|
+
.Fn archive_write_open .
|
|
83
|
+
.It Fn archive_write_open_fd
|
|
84
|
+
A convenience form of
|
|
85
|
+
.Fn archive_write_open
|
|
86
|
+
that accepts a file descriptor.
|
|
87
|
+
The
|
|
88
|
+
.Fn archive_write_open_fd
|
|
89
|
+
function is safe for use with tape drives or other
|
|
90
|
+
block-oriented devices.
|
|
91
|
+
.It Fn archive_write_open_FILE
|
|
92
|
+
A convenience form of
|
|
93
|
+
.Fn archive_write_open
|
|
94
|
+
that accepts a
|
|
95
|
+
.Ft "FILE *"
|
|
96
|
+
pointer.
|
|
97
|
+
Note that
|
|
98
|
+
.Fn archive_write_open_FILE
|
|
99
|
+
is not safe for writing to tape drives or other devices
|
|
100
|
+
that require correct blocking.
|
|
101
|
+
.It Fn archive_write_open_file
|
|
102
|
+
A deprecated synonym for
|
|
103
|
+
.Fn archive_write_open_filename .
|
|
104
|
+
.It Fn archive_write_open_filename
|
|
105
|
+
A convenience form of
|
|
106
|
+
.Fn archive_write_open
|
|
107
|
+
that accepts a filename.
|
|
108
|
+
A NULL argument indicates that the output should be written to standard output;
|
|
109
|
+
an argument of
|
|
110
|
+
.Dq -
|
|
111
|
+
will open a file with that name.
|
|
112
|
+
If you have not invoked
|
|
113
|
+
.Fn archive_write_set_bytes_in_last_block ,
|
|
114
|
+
then
|
|
115
|
+
.Fn archive_write_open_filename
|
|
116
|
+
will adjust the last-block padding depending on the file:
|
|
117
|
+
it will enable padding when writing to standard output or
|
|
118
|
+
to a character or block device node, it will disable padding otherwise.
|
|
119
|
+
You can override this by manually invoking
|
|
120
|
+
.Fn archive_write_set_bytes_in_last_block
|
|
121
|
+
before calling
|
|
122
|
+
.Fn archive_write_open2 .
|
|
123
|
+
The
|
|
124
|
+
.Fn archive_write_open_filename
|
|
125
|
+
function is safe for use with tape drives or other
|
|
126
|
+
block-oriented devices.
|
|
127
|
+
.It Fn archive_write_open_memory
|
|
128
|
+
A convenience form of
|
|
129
|
+
.Fn archive_write_open2
|
|
130
|
+
that accepts a pointer to a block of memory that will receive
|
|
131
|
+
the archive.
|
|
132
|
+
The final
|
|
133
|
+
.Ft "size_t *"
|
|
134
|
+
argument points to a variable that will be updated
|
|
135
|
+
after each write to reflect how much of the buffer
|
|
136
|
+
is currently in use.
|
|
137
|
+
You should be careful to ensure that this variable
|
|
138
|
+
remains allocated until after the archive is
|
|
139
|
+
closed.
|
|
140
|
+
This function will disable padding unless you
|
|
141
|
+
have specifically set the block size.
|
|
142
|
+
.El
|
|
143
|
+
More information about the
|
|
144
|
+
.Va struct archive
|
|
145
|
+
object and the overall design of the library can be found in the
|
|
146
|
+
.Xr libarchive 3
|
|
147
|
+
overview.
|
|
148
|
+
.Pp
|
|
149
|
+
Note that the convenience forms above vary in how
|
|
150
|
+
they block the output.
|
|
151
|
+
See
|
|
152
|
+
.Xr archive_write_blocksize 3
|
|
153
|
+
if you need to control the block size used for writes
|
|
154
|
+
or the end-of-file padding behavior.
|
|
155
|
+
.\"
|
|
156
|
+
.Sh CLIENT CALLBACKS
|
|
157
|
+
To use this library, you will need to define and register
|
|
158
|
+
callback functions that will be invoked to write data to the
|
|
159
|
+
resulting archive.
|
|
160
|
+
These functions are registered by calling
|
|
161
|
+
.Fn archive_write_open2 :
|
|
162
|
+
.Bl -item -offset indent
|
|
163
|
+
.It
|
|
164
|
+
.Ft typedef int
|
|
165
|
+
.Fn archive_open_callback "struct archive *" "void *client_data"
|
|
166
|
+
.El
|
|
167
|
+
.Pp
|
|
168
|
+
The open callback is invoked by
|
|
169
|
+
.Fn archive_write_open .
|
|
170
|
+
It should return
|
|
171
|
+
.Cm ARCHIVE_OK
|
|
172
|
+
if the underlying file or data source is successfully
|
|
173
|
+
opened.
|
|
174
|
+
If the open fails, it should call
|
|
175
|
+
.Fn archive_set_error
|
|
176
|
+
to register an error code and message and return
|
|
177
|
+
.Cm ARCHIVE_FATAL .
|
|
178
|
+
Please note that if open fails, close is not called and resources must be
|
|
179
|
+
freed inside the open callback or with the free callback.
|
|
180
|
+
.Bl -item -offset indent
|
|
181
|
+
.It
|
|
182
|
+
.Ft typedef la_ssize_t
|
|
183
|
+
.Fo archive_write_callback
|
|
184
|
+
.Fa "struct archive *"
|
|
185
|
+
.Fa "void *client_data"
|
|
186
|
+
.Fa "const void *buffer"
|
|
187
|
+
.Fa "size_t length"
|
|
188
|
+
.Fc
|
|
189
|
+
.El
|
|
190
|
+
.Pp
|
|
191
|
+
The write callback is invoked whenever the library
|
|
192
|
+
needs to write raw bytes to the archive.
|
|
193
|
+
For correct blocking, each call to the write callback function
|
|
194
|
+
should translate into a single
|
|
195
|
+
.Xr write 2
|
|
196
|
+
system call.
|
|
197
|
+
This is especially critical when writing archives to tape drives.
|
|
198
|
+
On success, the write callback should return the
|
|
199
|
+
number of bytes actually written.
|
|
200
|
+
On error, the callback should invoke
|
|
201
|
+
.Fn archive_set_error
|
|
202
|
+
to register an error code and message and return -1.
|
|
203
|
+
.Bl -item -offset indent
|
|
204
|
+
.It
|
|
205
|
+
.Ft typedef int
|
|
206
|
+
.Fn archive_close_callback "struct archive *" "void *client_data"
|
|
207
|
+
.El
|
|
208
|
+
.Pp
|
|
209
|
+
The close callback is invoked by archive_close when
|
|
210
|
+
the archive processing is complete. If the open callback fails, the close
|
|
211
|
+
callback is not invoked.
|
|
212
|
+
The callback should return
|
|
213
|
+
.Cm ARCHIVE_OK
|
|
214
|
+
on success.
|
|
215
|
+
On failure, the callback should invoke
|
|
216
|
+
.Fn archive_set_error
|
|
217
|
+
to register an error code and message and
|
|
218
|
+
return
|
|
219
|
+
.Cm ARCHIVE_FATAL .
|
|
220
|
+
.Bl -item -offset indent
|
|
221
|
+
.It
|
|
222
|
+
.Ft typedef int
|
|
223
|
+
.Fn archive_free_callback "struct archive *" "void *client_data"
|
|
224
|
+
.El
|
|
225
|
+
.Pp
|
|
226
|
+
The free callback is always invoked on archive_free.
|
|
227
|
+
The return code of this callback is not processed.
|
|
228
|
+
.Pp
|
|
229
|
+
Note that if the client-provided write callback function
|
|
230
|
+
returns a non-zero value, that error will be propagated back to the caller
|
|
231
|
+
through whatever API function resulted in that call, which
|
|
232
|
+
may include
|
|
233
|
+
.Fn archive_write_header ,
|
|
234
|
+
.Fn archive_write_data ,
|
|
235
|
+
.Fn archive_write_close ,
|
|
236
|
+
.Fn archive_write_finish ,
|
|
237
|
+
or
|
|
238
|
+
.Fn archive_write_free .
|
|
239
|
+
The client callback can call
|
|
240
|
+
.Fn archive_set_error
|
|
241
|
+
to provide values that can then be retrieved by
|
|
242
|
+
.Fn archive_errno
|
|
243
|
+
and
|
|
244
|
+
.Fn archive_error_string .
|
|
245
|
+
.\" .Sh EXAMPLE
|
|
246
|
+
.Sh RETURN VALUES
|
|
247
|
+
These functions return
|
|
248
|
+
.Cm ARCHIVE_OK
|
|
249
|
+
on success, or
|
|
250
|
+
.Cm ARCHIVE_FATAL .
|
|
251
|
+
.\"
|
|
252
|
+
.Sh ERRORS
|
|
253
|
+
Detailed error codes and textual descriptions are available from the
|
|
254
|
+
.Fn archive_errno
|
|
255
|
+
and
|
|
256
|
+
.Fn archive_error_string
|
|
257
|
+
functions.
|
|
258
|
+
.\"
|
|
259
|
+
.Sh SEE ALSO
|
|
260
|
+
.Xr tar 1 ,
|
|
261
|
+
.Xr archive_write 3 ,
|
|
262
|
+
.Xr archive_write_blocksize 3 ,
|
|
263
|
+
.Xr archive_write_filter 3 ,
|
|
264
|
+
.Xr archive_write_format 3 ,
|
|
265
|
+
.Xr archive_write_new 3 ,
|
|
266
|
+
.Xr archive_write_set_options 3 ,
|
|
267
|
+
.Xr libarchive 3 ,
|
|
268
|
+
.Xr cpio 5 ,
|
|
269
|
+
.Xr mtree 5 ,
|
|
270
|
+
.Xr tar 5
|
|
@@ -0,0 +1,141 @@
|
|
|
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
|
+
#ifdef HAVE_SYS_STAT_H
|
|
29
|
+
#include <sys/stat.h>
|
|
30
|
+
#endif
|
|
31
|
+
#ifdef HAVE_ERRNO_H
|
|
32
|
+
#include <errno.h>
|
|
33
|
+
#endif
|
|
34
|
+
#ifdef HAVE_FCNTL_H
|
|
35
|
+
#include <fcntl.h>
|
|
36
|
+
#endif
|
|
37
|
+
#ifdef HAVE_IO_H
|
|
38
|
+
#include <io.h>
|
|
39
|
+
#endif
|
|
40
|
+
#ifdef HAVE_STDLIB_H
|
|
41
|
+
#include <stdlib.h>
|
|
42
|
+
#endif
|
|
43
|
+
#ifdef HAVE_STRING_H
|
|
44
|
+
#include <string.h>
|
|
45
|
+
#endif
|
|
46
|
+
#ifdef HAVE_UNISTD_H
|
|
47
|
+
#include <unistd.h>
|
|
48
|
+
#endif
|
|
49
|
+
|
|
50
|
+
#include "archive.h"
|
|
51
|
+
|
|
52
|
+
struct write_fd_data {
|
|
53
|
+
int fd;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
static int file_free(struct archive *, void *);
|
|
57
|
+
static int file_open(struct archive *, void *);
|
|
58
|
+
static ssize_t file_write(struct archive *, void *, const void *buff, size_t);
|
|
59
|
+
|
|
60
|
+
int
|
|
61
|
+
archive_write_open_fd(struct archive *a, int fd)
|
|
62
|
+
{
|
|
63
|
+
struct write_fd_data *mine;
|
|
64
|
+
|
|
65
|
+
mine = malloc(sizeof(*mine));
|
|
66
|
+
if (mine == NULL) {
|
|
67
|
+
archive_set_error(a, ENOMEM, "No memory");
|
|
68
|
+
return (ARCHIVE_FATAL);
|
|
69
|
+
}
|
|
70
|
+
mine->fd = fd;
|
|
71
|
+
#if defined(__CYGWIN__) || defined(_WIN32)
|
|
72
|
+
setmode(mine->fd, O_BINARY);
|
|
73
|
+
#endif
|
|
74
|
+
return (archive_write_open2(a, mine,
|
|
75
|
+
file_open, file_write, NULL, file_free));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static int
|
|
79
|
+
file_open(struct archive *a, void *client_data)
|
|
80
|
+
{
|
|
81
|
+
struct write_fd_data *mine;
|
|
82
|
+
struct stat st;
|
|
83
|
+
|
|
84
|
+
mine = (struct write_fd_data *)client_data;
|
|
85
|
+
|
|
86
|
+
if (fstat(mine->fd, &st) != 0) {
|
|
87
|
+
archive_set_error(a, errno, "Couldn't stat fd %d", mine->fd);
|
|
88
|
+
return (ARCHIVE_FATAL);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/*
|
|
92
|
+
* If this is a regular file, don't add it to itself.
|
|
93
|
+
*/
|
|
94
|
+
if (S_ISREG(st.st_mode))
|
|
95
|
+
archive_write_set_skip_file(a, st.st_dev, st.st_ino);
|
|
96
|
+
|
|
97
|
+
/*
|
|
98
|
+
* If client hasn't explicitly set the last block handling,
|
|
99
|
+
* then set it here.
|
|
100
|
+
*/
|
|
101
|
+
if (archive_write_get_bytes_in_last_block(a) < 0) {
|
|
102
|
+
/* If the output is a block or character device, fifo,
|
|
103
|
+
* or stdout, pad the last block, otherwise leave it
|
|
104
|
+
* unpadded. */
|
|
105
|
+
if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode) ||
|
|
106
|
+
S_ISFIFO(st.st_mode) || (mine->fd == 1))
|
|
107
|
+
/* Last block will be fully padded. */
|
|
108
|
+
archive_write_set_bytes_in_last_block(a, 0);
|
|
109
|
+
else
|
|
110
|
+
archive_write_set_bytes_in_last_block(a, 1);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return (ARCHIVE_OK);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
static ssize_t
|
|
117
|
+
file_write(struct archive *a, void *client_data, const void *buff, size_t length)
|
|
118
|
+
{
|
|
119
|
+
struct write_fd_data *mine;
|
|
120
|
+
ssize_t bytesWritten;
|
|
121
|
+
|
|
122
|
+
mine = (struct write_fd_data *)client_data;
|
|
123
|
+
for (;;) {
|
|
124
|
+
bytesWritten = write(mine->fd, buff, length);
|
|
125
|
+
if (bytesWritten < 0) {
|
|
126
|
+
if (errno == EINTR)
|
|
127
|
+
continue;
|
|
128
|
+
archive_set_error(a, errno, "Write error");
|
|
129
|
+
return (-1);
|
|
130
|
+
}
|
|
131
|
+
return (bytesWritten);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
static int
|
|
136
|
+
file_free(struct archive *a, void *client_data)
|
|
137
|
+
{
|
|
138
|
+
(void)a; /* UNUSED */
|
|
139
|
+
free(client_data);
|
|
140
|
+
return (ARCHIVE_OK);
|
|
141
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
#ifdef HAVE_SYS_STAT_H
|
|
29
|
+
#include <sys/stat.h>
|
|
30
|
+
#endif
|
|
31
|
+
#ifdef HAVE_ERRNO_H
|
|
32
|
+
#include <errno.h>
|
|
33
|
+
#endif
|
|
34
|
+
#ifdef HAVE_FCNTL_H
|
|
35
|
+
#include <fcntl.h>
|
|
36
|
+
#endif
|
|
37
|
+
#ifdef HAVE_STDLIB_H
|
|
38
|
+
#include <stdlib.h>
|
|
39
|
+
#endif
|
|
40
|
+
#ifdef HAVE_STRING_H
|
|
41
|
+
#include <string.h>
|
|
42
|
+
#endif
|
|
43
|
+
#ifdef HAVE_UNISTD_H
|
|
44
|
+
#include <unistd.h>
|
|
45
|
+
#endif
|
|
46
|
+
|
|
47
|
+
#include "archive.h"
|
|
48
|
+
|
|
49
|
+
struct write_FILE_data {
|
|
50
|
+
FILE *f;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
static int file_free(struct archive *, void *);
|
|
54
|
+
static int file_open(struct archive *, void *);
|
|
55
|
+
static ssize_t file_write(struct archive *, void *, const void *buff, size_t);
|
|
56
|
+
|
|
57
|
+
int
|
|
58
|
+
archive_write_open_FILE(struct archive *a, FILE *f)
|
|
59
|
+
{
|
|
60
|
+
struct write_FILE_data *mine;
|
|
61
|
+
|
|
62
|
+
mine = malloc(sizeof(*mine));
|
|
63
|
+
if (mine == NULL) {
|
|
64
|
+
archive_set_error(a, ENOMEM, "No memory");
|
|
65
|
+
return (ARCHIVE_FATAL);
|
|
66
|
+
}
|
|
67
|
+
mine->f = f;
|
|
68
|
+
return (archive_write_open2(a, mine, file_open, file_write,
|
|
69
|
+
NULL, file_free));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
static int
|
|
73
|
+
file_open(struct archive *a, void *client_data)
|
|
74
|
+
{
|
|
75
|
+
(void)a; /* UNUSED */
|
|
76
|
+
(void)client_data; /* UNUSED */
|
|
77
|
+
|
|
78
|
+
return (ARCHIVE_OK);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static ssize_t
|
|
82
|
+
file_write(struct archive *a, void *client_data, const void *buff, size_t length)
|
|
83
|
+
{
|
|
84
|
+
struct write_FILE_data *mine;
|
|
85
|
+
size_t bytesWritten;
|
|
86
|
+
|
|
87
|
+
mine = client_data;
|
|
88
|
+
bytesWritten = fwrite(buff, 1, length, mine->f);
|
|
89
|
+
if (bytesWritten != length) {
|
|
90
|
+
archive_set_error(a, errno, "Write error");
|
|
91
|
+
return (-1);
|
|
92
|
+
}
|
|
93
|
+
return (bytesWritten);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static int
|
|
97
|
+
file_free(struct archive *a, void *client_data)
|
|
98
|
+
{
|
|
99
|
+
(void)a; /* UNUSED */
|
|
100
|
+
free(client_data);
|
|
101
|
+
return (ARCHIVE_OK);
|
|
102
|
+
}
|